View Source Req.Response (req v0.3.0-dev)
The response struct.
Fields:
:status- the HTTP status code:headers- the HTTP response headers:body- the HTTP response body:private- a map reserved for libraries and frameworks to use. Prefix the keys with the name of your project to avoid any future conflicts. Only acceptsatom/0keys.
Link to this section Summary
Functions
Returns the values of the header specified by key.
Gets the value for a specific private key.
Builds or updates a response with JSON body.
Returns a new response.
Adds a new response header (key) if not present, otherwise replaces the
previous value of that header with value.
Assigns a private key to value.
Link to this section Types
Link to this section Functions
Returns the values of the header specified by key.
examples
Examples
iex> Req.Response.get_header(response, "content-type")
["application/json"]
Gets the value for a specific private key.
Builds or updates a response with JSON body.
example
Example
iex> Req.Response.json(%{hello: 42})
%Req.Response{
status: 200,
headers: [{"content-type", "application/json"}],
body: ~s|{"hello":42}|
}
iex> resp = Req.Response.new()
iex> Req.Response.json(resp, %{hello: 42})
%Req.Response{
status: 200,
headers: [{"content-type", "application/json"}],
body: ~s|{"hello":42}|
}
Returns a new response.
Adds a new response header (key) if not present, otherwise replaces the
previous value of that header with value.
examples
Examples
iex> Req.Response.put_header(response, "content-type", "application/json").headers
[{"content-type", "application/json"}]
Assigns a private key to value.