Clova v0.2.0 Clova.Parser View Source
Parses the request body and signature header.
Usage:
plug Plug.Parsers, parsers: [Clova.Parser]
The request body is parsed into a Clova.Request
struct, which is later provided
as the request
argument to the Clova
callbacks. Raises Plug.Parsers.ParseError
if
the request body could not be decoded.
The request signature is parsed from the signaturecek
header and placed into the :signature
assign as an {:ok, signature}
tuple if successful, or if the signature could not be parsed,
an {:error, reason}
tuple.
This module also stores the original raw request body in the :raw_body
assign,
because it is required to validate the request signature. For request validation it
is recommended to use the Clova.Validator
plug.
Link to this section Summary
Functions
Callback implementation for Plug.Parsers.init/1
Attempts to parse the connection’s request body given the content-type type, subtype, and its parameters
Link to this section Functions
Callback implementation for Plug.Parsers.init/1
.
Attempts to parse the connection’s request body given the content-type type, subtype, and its parameters.
The arguments are:
- the
Plug.Conn
connection type
, the content-type type (e.g.,"x-sample"
for the"x-sample/json"
content-type)subtype
, the content-type subtype (e.g.,"json"
for the"x-sample/json"
content-type)params
, the content-type parameters (e.g.,%{"foo" => "bar"}
for the"text/plain; foo=bar"
content-type)
This function should return:
{:ok, body_params, conn}
if the parser is able to handle the given content-type;body_params
should be a map{:next, conn}
if the next parser should be invoked{:error, :too_large, conn}
if the request goes over the given limit
Callback implementation for Plug.Parsers.parse/5
.