arizona_cowboy_handler (arizona_cowboy v0.1.0)
View SourceThe Cowboy adapter's single handler: every request reaches it through the
listener's catch-all route, and it routes with arizona_route_table.
What each route kind answers comes from core -- arizona_http:reply/3 for a
page, arizona_ws:upgrade/3 for a WebSocket, arizona_controller:dispatch/3
for a controller -- and this module only maps it onto Cowboy, wrapping it in the
route's response transforms (arizona_http_transforms). It is also the
cowboy_loop handler of a controller's {loop, ...} reply and the
cowboy_websocket handler of a live session.
Summary
Functions
Cowboy cowboy_loop info/3: hands a message to the controller's loop.
Cowboy init/2: routes the request and answers it.
Cowboy terminate/3. A loop that ends without having stopped itself lost its
client, which the controller hears as {arizona_disconnect, Reason}.
Cowboy websocket_handle/2: text frames go to the socket.
Cowboy websocket_info/2: a drain, or a message for the socket.
Cowboy websocket_init/1: joins the listener's session group (how a drain
reaches the session) and starts the Arizona socket.
Functions
-spec info(Msg, Req, State) -> {ok, Req, State} | {stop, Req, State} when Msg :: term(), Req :: cowboy_req:req(), State :: map().
Cowboy cowboy_loop info/3: hands a message to the controller's loop.
-spec init(Req, Listener) -> Result when Req :: cowboy_req:req(), Listener :: atom(), Result :: {ok, Req, Listener} | {cowboy_loop, Req, map()} | {cowboy_websocket, Req, map(), map()}.
Cowboy init/2: routes the request and answers it.
-spec terminate(Reason, Req, State) -> ok when Reason :: term(), Req :: cowboy_req:req() | map(), State :: term().
Cowboy terminate/3. A loop that ends without having stopped itself lost its
client, which the controller hears as {arizona_disconnect, Reason}.
-spec websocket_handle(Frame, State) -> {[cow_ws:frame()], State} when Frame :: cow_ws:frame() | ping | pong, State :: map().
Cowboy websocket_handle/2: text frames go to the socket.
-spec websocket_info(Msg, State) -> {[cow_ws:frame()], State} when Msg :: term(), State :: map().
Cowboy websocket_info/2: a drain, or a message for the socket.
-spec websocket_init(State) -> {[cow_ws:frame()], State} when State :: map().
Cowboy websocket_init/1: joins the listener's session group (how a drain
reaches the session) and starts the Arizona socket.