Skip to main content

Session.endpoint(route, *, method=‘GET’)

Create a custom endpoint at f"/proxy/{route}".
Calling this method overrides atoti.Session.proxy’s url.
The endpoint logic is written in Python but the endpoint is exposed by Atoti Server. This allows to deploy the project in a container or a VM with a single opened port (the one of Atoti Server) instead of two. The decorated function must:
  • take three parameters with respective types:
  • return a response body as JSON convertible data
  • Parameters:
    • route (str) – The template of the path after "/proxy". For instance, if "foo/bar" is passed, a request to "/proxy/foo/bar?query=string" will match. Path parameters can be configured by wrapping their name in curly braces in the template.
    • method (Literal [ ‘DELETE’ , ‘GET’ , ‘PATCH’ , ‘POST’ , ‘PUT’ ]) – The HTTP method the request must be using to trigger this endpoint. DELETE, PATCH, POST, and PUT requests can have a body but it must be JSON.
  • Return type: Callable[[Callable[[Request, User, Session], JsonValue]], Callable[[Request, User, Session], JsonValue]]

Example

The full flow is: