3.0.ipv8.REST.rest_manager

Classes

Functions

Module Contents

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

Middleware to check for authorized REST access.

api_key
async __call__(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) aiohttp.web_response.StreamResponse | 3.0.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 3.0.ipv8.REST.rest_manager.cors_middleware(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) 3.0.ipv8.REST.base_endpoint.Response | aiohttp.web_response.StreamResponse

Cross-origin resource sharing middleware.

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

Middleware to catch call errors when handling requests.

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

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

_logger
session
site: aiohttp.web.TCPSite | None = None
root_endpoint: 3.0.ipv8.REST.base_endpoint.BaseEndpoint | None = None
_root_endpoint_class
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.