content v0.1.0 Content
Content
handles Content Negotation in any Elixir/Phoenix App.
Please see: github.com/dwyl/content for detail.
Link to this section Summary
Functions
get_accept_header/2
gets the "accept" header from req_headers.
Defaults to "text/html" if no header is set.
init/1
initialises the options passed in and makes them
available in the lifecycle of the call/2
invocation (below).
When invoking the Content
plug in a Phoenix router pipeline,
we pass in a Map containing a key html_plugs
with a list of
plugs that need to be run when the accept header is "html".
See implimentation docs for more detail/clarity.
reply/5
gets the "accept" header from req_headers.
Defaults to "text/html" if no header is set.
Link to this section Functions
call(conn, options)
call/2
is invoked to handle each HTTP request which Content
inspects.
If the accept header is "html", execute the html_plugs
for that request.
If the accept header contains "json" return the conn
unmodified.
get_accept_header(conn)
get_accept_header/2
gets the "accept" header from req_headers.
Defaults to "text/html" if no header is set.
init(options)
init/1
initialises the options passed in and makes them
available in the lifecycle of the call/2
invocation (below).
When invoking the Content
plug in a Phoenix router pipeline,
we pass in a Map containing a key html_plugs
with a list of
plugs that need to be run when the accept header is "html".
See implimentation docs for more detail/clarity.
reply(conn, render, template, json, data)
reply/5
gets the "accept" header from req_headers.
Defaults to "text/html" if no header is set.