latest.ipv8.REST.rest_manager

Module Contents

Classes

ApiKeyMiddleware

Middleware to check for authorized REST access.

RESTManager

This class is responsible for managing the startup and closing of the HTTP API.

Functions

cors_middleware(...)

Cross-origin resource sharing middleware.

error_middleware(...)

Middleware to catch call errors when handling requests.

class latest.ipv8.REST.rest_manager.ApiKeyMiddleware(api_key: str | None)

Middleware to check for authorized REST access.

async __call__(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) aiohttp.web_response.StreamResponse | latest.ipv8.REST.base_endpoint.Response

Intercept requests that are not authorized.

authenticate(request: aiohttp.abc.Request) bool

Check if the given request is authorized.

async latest.ipv8.REST.rest_manager.cors_middleware(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) latest.ipv8.REST.base_endpoint.Response | aiohttp.web_response.StreamResponse

Cross-origin resource sharing middleware.

async latest.ipv8.REST.rest_manager.error_middleware(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) latest.ipv8.REST.base_endpoint.Response | aiohttp.web_response.StreamResponse

Middleware to catch call errors when handling requests.

class latest.ipv8.REST.rest_manager.RESTManager(session: object, root_endpoint_class: type[latest.ipv8.REST.base_endpoint.BaseEndpoint] | None = None)

This class is responsible for managing the startup and closing of the HTTP API.

async start(port: int = 8085, host: str = '127.0.0.1', api_key: str | None = None, ssl_context: aiohttp.connector.SSLContext | None = None) None

Starts the HTTP API with the listen port as specified in the session configuration.

async start_site(runner: aiohttp.web_runner.BaseRunner, host: str | None, port: int | None, ssl_context: aiohttp.connector.SSLContext | None) None

Create and start the internal TCP-based site.

async stop() None

Stop the HTTP API and return when the server has shut down.