3.0.ipv8.REST.rest_manager ========================== .. py:module:: 3.0.ipv8.REST.rest_manager Classes ------- .. autoapisummary:: 3.0.ipv8.REST.rest_manager.ApiKeyMiddleware 3.0.ipv8.REST.rest_manager.RESTManager Functions --------- .. autoapisummary:: 3.0.ipv8.REST.rest_manager.cors_middleware 3.0.ipv8.REST.rest_manager.error_middleware Module Contents --------------- .. py:class:: ApiKeyMiddleware(api_key: str | None) Middleware to check for authorized REST access. .. py:attribute:: api_key .. py:method:: __call__(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) -> aiohttp.web_response.StreamResponse | 3.0.ipv8.REST.base_endpoint.Response :async: Intercept requests that are not authorized. .. py:method:: authenticate(request: aiohttp.abc.Request) -> bool Check if the given request is authorized. .. py:function:: cors_middleware(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) -> 3.0.ipv8.REST.base_endpoint.Response | aiohttp.web_response.StreamResponse :async: Cross-origin resource sharing middleware. .. py:function:: error_middleware(request: aiohttp.abc.Request, handler: aiohttp.typedefs.Handler) -> 3.0.ipv8.REST.base_endpoint.Response | aiohttp.web_response.StreamResponse :async: Middleware to catch call errors when handling requests. .. py:class:: 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. .. py:attribute:: _logger .. py:attribute:: session .. py:attribute:: site :type: aiohttp.web.TCPSite | None :value: None .. py:attribute:: root_endpoint :type: 3.0.ipv8.REST.base_endpoint.BaseEndpoint | None :value: None .. py:attribute:: _root_endpoint_class .. py:method:: start(port: int = 8085, host: str = '127.0.0.1', api_key: str | None = None, ssl_context: aiohttp.connector.SSLContext | None = None) -> None :async: Starts the HTTP API with the listen port as specified in the session configuration. .. py:method:: start_site(runner: aiohttp.web_runner.BaseRunner, host: str | None, port: int | None, ssl_context: aiohttp.connector.SSLContext | None) -> None :async: Create and start the internal TCP-based site. .. py:method:: stop() -> None :async: Stop the HTTP API and return when the server has shut down.