arizona_http (arizona v0.4.0)
View SourceShared HTTP render pipeline for transport adapters that serve an Arizona view as the page response.
Runs route middlewares against an already-wrapped
arizona_req:request(), then dispatches to
arizona_render:render_view/2 and returns either a halt
signal (middleware refused to continue), the rendered page body,
or a crash/error page body. The caller is responsible for wrapping
the native request beforehand and translating the result into its
transport's native reply shape.
Flow
- Run
arizona_middleware:apply_middlewares/3with the route'sbindings. - On
{halt, HaltReq}-- return{halt, HaltReq}unchanged; the caller decodes the stashed redirect (arizona_req:halted_redirect/1) or status and ships the reply (a403when the middleware stashed neither). - On
{cont, Req1, Bindings1}-- callarizona_render:render_view/2with the route'slayout/on_mount. Return{ok, 200, ContentType, Page, Req1}or, on crash or a stashed hot-reload error,{error, 500, ContentType, ErrorPage, Req1}(the threaded req carries any response headers/cookies for the transport to flush).ContentTypeis the rendered document's media type, answered by its render backend, so a?nativeroute serves JSON and an HTML one HTML.
Summary
Functions
Runs the full render pipeline for Handler against an already-wrapped
arizona_req:request().
render/3 folded into the response a server adapter sends: a halt becomes its
arizona_req:halt_reply/1 (empty body), a rendered page (or its error page)
gets arizona_req:flush/1's lines then its content-type. Either way the
session is committed and the header lines are in send order, so the adapter
only adds its own framing (a content-length) and replies.
Types
-nominal error_info() :: #{class := error | exit | throw, reason := term(), stacktrace := erlang:stacktrace(), reload_url => binary() | undefined}.
-nominal reply() :: {arizona_req:resp_status(), [{binary(), binary()}], iodata(), arizona_req:request()}.
-nominal result() :: {halt, arizona_req:request()} | {ok, arizona_req:resp_status(), ContentType :: binary(), iolist(), arizona_req:request()} | {error, 500, ContentType :: binary(), iolist(), arizona_req:request()}.
Functions
-spec render(Handler, ArzReq, Opts) -> result() when Handler :: module(), ArzReq :: arizona_req:request(), Opts :: arizona_live:route_opts().
Runs the full render pipeline for Handler against an already-wrapped
arizona_req:request().
-spec reply(Handler, ArzReq, Opts) -> reply() when Handler :: module(), ArzReq :: arizona_req:request(), Opts :: arizona_live:route_opts().
render/3 folded into the response a server adapter sends: a halt becomes its
arizona_req:halt_reply/1 (empty body), a rendered page (or its error page)
gets arizona_req:flush/1's lines then its content-type. Either way the
session is committed and the header lines are in send order, so the adapter
only adds its own framing (a content-length) and replies.