tribler.core.restapi.rest_endpoint

Attributes

HTTP_BAD_REQUEST

HTTP_UNAUTHORIZED

HTTP_NOT_FOUND

HTTP_REQUEST_ENTITY_TOO_LARGE

HTTP_INTERNAL_SERVER_ERROR

MAX_REQUEST_SIZE

Classes

RESTEndpoint

The base class for all Tribler REST endpoints.

RootEndpoint

Create a new root endpoint.

RESTResponse

A Tribler response for web requests.

Functions

return_handled_exception(→ RESTResponse)

Create a RESTResponse that tells the use that an exception is handled.

Module Contents

tribler.core.restapi.rest_endpoint.HTTP_BAD_REQUEST = 400
tribler.core.restapi.rest_endpoint.HTTP_UNAUTHORIZED = 401
tribler.core.restapi.rest_endpoint.HTTP_NOT_FOUND = 404
tribler.core.restapi.rest_endpoint.HTTP_REQUEST_ENTITY_TOO_LARGE = 413
tribler.core.restapi.rest_endpoint.HTTP_INTERNAL_SERVER_ERROR = 500
tribler.core.restapi.rest_endpoint.MAX_REQUEST_SIZE = 16777216
class tribler.core.restapi.rest_endpoint.RESTEndpoint(middlewares: tuple = (), client_max_size: int = MAX_REQUEST_SIZE)

Bases: ipv8.taskmanager.TaskManager

The base class for all Tribler REST endpoints.

path: str
_logger
app
class tribler.core.restapi.rest_endpoint.RootEndpoint(middlewares: tuple = (), client_max_size: int = MAX_REQUEST_SIZE)

Bases: 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.

endpoints: dict[str, RESTEndpoint | ipv8.REST.root_endpoint.RootEndpoint]
add_endpoint(prefix: str, endpoint: RESTEndpoint | ipv8.REST.root_endpoint.RootEndpoint) None

Add an endpoint to this root endpoint.

class tribler.core.restapi.rest_endpoint.RESTResponse(body: dict | list | bytes | str | None = None, headers: dict | None = None, content_type: str | None = None, status: int = 200, **kwargs)

Bases: aiohttp.web.Response

A Tribler response for web requests.

JSON-compatible response bodies are automatically converted to JSON type.

tribler.core.restapi.rest_endpoint.return_handled_exception(exception: Exception) RESTResponse

Create a RESTResponse that tells the use that an exception is handled.

Parameters:

exception – the handled exception

Returns:

JSON dictionary describing the exception