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 DefaultControllerResolver[source]¶
Bases:
IControllerResolver
- async resolve(request)[source]¶
- Parameters:
request (HttpRequest)
- class IControllerResolver[source]¶
Bases:
Protocol
- __init__(*args, **kwargs)¶
- async resolve(request)[source]¶
- Parameters:
request (HttpRequest)
- class ProxyControllerResolver[source]¶
Bases:
DefaultControllerResolver
- add(endpoint, *, http_client, dispatcher=None, ControllerType=None)[source]¶
- Parameters:
endpoint (Endpoint)
http_client (AsyncClient)
dispatcher (IAsyncEventDispatcher | None)
ControllerType (Type[HttpProxyController] | None)
- add_controller(port, controller)[source]¶
- Parameters:
port (int)
controller (IAsyncController)
- async resolve(request)[source]¶
- Parameters:
request (HttpRequest)
- property ports¶
- class RoutingController[source]¶
Bases:
object
- RouterType¶
alias of
Router
- RouterArguments = <harp.utils.arguments.Arguments object>¶
- prefix = None¶
- async dump_request_controller(request)[source]¶
TODO: use orjson ?
- Parameters:
request (HttpRequest)