tribler.core.restapi.rest_endpoint ================================== .. py:module:: tribler.core.restapi.rest_endpoint Attributes ---------- .. autoapisummary:: tribler.core.restapi.rest_endpoint.HTTP_BAD_REQUEST tribler.core.restapi.rest_endpoint.HTTP_UNAUTHORIZED tribler.core.restapi.rest_endpoint.HTTP_NOT_FOUND tribler.core.restapi.rest_endpoint.HTTP_REQUEST_ENTITY_TOO_LARGE tribler.core.restapi.rest_endpoint.HTTP_INTERNAL_SERVER_ERROR tribler.core.restapi.rest_endpoint.MAX_REQUEST_SIZE Classes ------- .. autoapisummary:: tribler.core.restapi.rest_endpoint.RESTEndpoint tribler.core.restapi.rest_endpoint.RootEndpoint tribler.core.restapi.rest_endpoint.RESTResponse Functions --------- .. autoapisummary:: tribler.core.restapi.rest_endpoint.return_handled_exception Module Contents --------------- .. py:data:: HTTP_BAD_REQUEST :value: 400 .. py:data:: HTTP_UNAUTHORIZED :value: 401 .. py:data:: HTTP_NOT_FOUND :value: 404 .. py:data:: HTTP_REQUEST_ENTITY_TOO_LARGE :value: 413 .. py:data:: HTTP_INTERNAL_SERVER_ERROR :value: 500 .. py:data:: MAX_REQUEST_SIZE :value: 16777216 .. py:class:: RESTEndpoint(middlewares: tuple = (), client_max_size: int = MAX_REQUEST_SIZE) Bases: :py:obj:`ipv8.taskmanager.TaskManager` The base class for all Tribler REST endpoints. .. py:attribute:: path :type: str .. py:attribute:: _logger .. py:attribute:: app .. py:class:: RootEndpoint(middlewares: tuple = (), client_max_size: int = MAX_REQUEST_SIZE) Bases: :py:obj:`RESTEndpoint` Create a new root endpoint. Essentially, this is the same as any other REST endpoint, but it is supposed to be the top in the hierarchy. .. py:attribute:: endpoints :type: dict[str, RESTEndpoint | ipv8.REST.root_endpoint.RootEndpoint] .. py:method:: add_endpoint(prefix: str, endpoint: RESTEndpoint | ipv8.REST.root_endpoint.RootEndpoint) -> None Add an endpoint to this root endpoint. .. py:class:: RESTResponse(body: dict | list | bytes | str | None = None, headers: dict | None = None, content_type: str | None = None, status: int = 200, **kwargs) Bases: :py:obj:`aiohttp.web.Response` A Tribler response for web requests. JSON-compatible response bodies are automatically converted to JSON type. .. py:function:: return_handled_exception(exception: Exception) -> RESTResponse Create a RESTResponse that tells the use that an exception is handled. :param exception: the handled exception :return: JSON dictionary describing the exception