arizona_cowboy_middleware (arizona_cowboy v0.1.0)

View Source

A Cowboy middleware serving the Arizona routes arizona_cowboy_server:mount/2 put on the listener it runs in, for a listener another framework owns.

Place it before the owner's router in the listener's middlewares. A request whose path an Arizona route matches is answered by arizona_cowboy_handler, exactly as on a listener this adapter started, and the rest of the chain does not run; any other request continues down the chain untouched. A path Arizona serves owns its methods too: a method no Arizona route allows there is answered 405 here rather than passed on.

cowboy:start_clear(my_listener, [{port, 8080}], #{
    middlewares => [arizona_cowboy_middleware, cowboy_router, cowboy_handler],
    env => #{dispatch => MyDispatch}
}),
ok = arizona_cowboy_server:mount(my_listener, #{routes => ArizonaRoutes}).

Summary

Functions

Cowboy execute/2: serves an Arizona route, or passes the request on.

Functions

execute(Req, Env)

-spec execute(Req, Env) -> {ok, Req, Env} | {stop, Req}
                 when Req :: cowboy_req:req(), Env :: cowboy_middleware:env().

Cowboy execute/2: serves an Arizona route, or passes the request on.