ja_serializer v0.15.0 JaSerializer.ContentTypeNegotiation View Source
This plug provides content type negotiation by validating the
content-type
and accept
headers.
The proper jsonapi.org content type is: application/vnd.api+json
.
As per the spec this plug does three things.
- Returns 415 unless the content-type header is correct.
- Returns 406 unless the accept header is correct.
- Registers a before send hook to set the content-type if not already set.
Usage
Just include in your plug stack:
plug JaSerializer.ContentTypeNegotiation
Link to this section Summary
Link to this section Functions
Link to this function
call(conn, opts) View Source
Callback implementation for Plug.call/2
.
Link to this function
init(opts) View Source
Callback implementation for Plug.init/1
.
Link to this function
set_content_type(conn, opts) View Source
Link to this function
verify_accepts(conn, opts) View Source
Link to this function