Aino.Handler behaviour (aino v0.2.0)

Process an incoming request from Aino

The handle/1 function is passed an Aino.Token.

The handler must return a token that contains three keys to return a response:

  • :response_status
  • :response_headers
  • :response_body

If the token does not contain these three keys, a 500 error is returned.

Inside your handler, you may wish to use several Aino.Middleware including Aino.Middleware.common/0.

Optionally, if you are implementing websockets, define sockets/0 in your handler.

Link to this section Summary

Callbacks

Process an incoming request from Aino

Return a list of socket handlers

Link to this section Callbacks

Specs

handle(map()) :: map()

Process an incoming request from Aino

The argument is an Aino.Token.

Link to this callback

sockets()

(optional)

Specs

sockets() :: [tuple()]

Return a list of socket handlers

[
  {"/socket", MyApp.Handler}
]

MyApp.Handler implements Aino.WebSocket.Handler.