Attention

This is the documentation for HARP Proxy, actually published as an early preview. Both the software and documentation are a work in progress, and although we already use it on various production servers, they may contain inaccuracies, typographical errors, huge mistakes and empty pages. We work hard to eradicate all mistakes and implement stuff, but it is a long and tedious process. We appreciate your patience and understanding. Of course, any help will be greatly appreciated.

Controllers (harp.controllers)

The Controllers (harp.controllers) package contains the routing and controller logic for the Harp framework.

You probably do not want to use this package unless you’re writing an extension for Harp.

Example usage:

from harp.controllers import RoutingController, GetHandler

class MyController(RoutingController):
    @GetHandler("/")
    async def index(self):
        return "Hello, world!"

Contents

class ControllerResolver[source]

Bases: Protocol

__init__(*args, **kwargs)
async resolve(request)[source]
Parameters:

request (HttpRequest)

class DefaultControllerResolver[source]

Bases: ControllerResolver

__init__(*, default_controller=None)[source]
async resolve(request)[source]
Parameters:

request (HttpRequest)

class ProxyControllerResolver[source]

Bases: DefaultControllerResolver

__init__(*, default_controller=None)[source]
add(port, controller)[source]
Parameters:

port (int | str)

async resolve(request)[source]
Parameters:

request (HttpRequest)

property ports
class RoutingController[source]

Bases: object

RouterType

alias of Router

__init__(*, handle_errors=True, router=None)[source]
configure()[source]
create_router()[source]
handle_error(exc, *, status=500)[source]
RouterArguments = <harp.utils.arguments.Arguments object>
prefix = None
AnyMethodHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

ConnectHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

DeleteHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

GetHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

HeadHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

OptionsHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

PatchHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

PostHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

PutHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

RouteHandler(*paths, methods=None, **opts)[source]
Parameters:
RouterPrefix(prefix)[source]
TraceHandler(*paths, **opts)[source]
Parameters:

paths (str | Pattern)

async dump_request_controller(request)[source]

TODO: use orjson ?

Parameters:

request (HttpRequest)

async not_found_controller()[source]

Submodules