raxx v0.10.1 Raxx.Response

HTTP responses from a Raxx application are encapsulated in a Raxx.Response struct.

The contents are itemised below:

statusThe HTTP status code for the response: 1xx, 2xx, 3xx, 4xx, 5xx
headersThe response headers as a map: %{"content-type" => ["text/plain"]}
bodyThe response body, by default an empty string.

Examples

iex> Response.ok().status
200

iex> Response.ok("Hello, World!").body
"Hello, World!"

iex> Response.ok([{"content-language", "en"}]).headers
[{"content-language", "en"}]

iex> Response.ok("Hello, World!", [{"content-type", "text/plain"}]).headers
[{"content-type", "text/plain"}]

Summary

Functions

Create a “202 Accepted” response

Create a “502 Bad Gateway” response

Create a “400 Bad Request” response

The response indicates that the client sent an incorrect request

Create a “409 Conflict” response

Create a “100 Continue” response

Create a “201 Created” response

Create a “417 Expectation Failed” response

Create a “403 Forbidden” response

Create a “302 Found” response

Create a “504 Gateway Timeout” response

Create a “410 Gone” response

Create a “505 HTTP Version Not Supported” response

The response is marked as an interim response

Create a “500 Internal Server Error” response

Create a “411 Length Required” response

Create a “405 Method Not Allowed” response

Create a “301 Moved Permanently” response

Create a “300 Multiple Choices” response

Create a “204 No Content” response

Create a “203 Non-Authoritative Information” response

Create a “406 Not Acceptable” response

Create a “404 Not Found” response

Create a “501 Not Implemented” response

Create a “304 Not Modified” response

Create a “200 OK” response

Create a “206 Partial Content” response

Create a “413 Payload Too Large” response

Create a “402 Payment Required” response

Create a “412 Precondition Failed” response

Create a “407 Proxy Authentication Required” response

Create a “416 Range Not Satisfiable” response

The response indicates that further action needs to be taken by the client

Create a “408 Request Timeout” response

Create a “205 Reset Content” response

Create a “303 See Other” response

The response indicates that the server is incapable of acting upon the request

Create a “503 Service Unavailable” response

The response indicates that client request was received, understood, and accepted

Create a “101 Switching Protocols” response

Create a “307 Temporary Redirect” response

Create a “401 Unauthorized” response

Create a “415 Unsupported Media Type” response

Create a “426 Upgrade Required” response

Create a “414 URI Too Long” response

Create a “305 Use Proxy” response

Functions

accepted(body \\ "", headers \\ [])

Create a “202 Accepted” response.

See module documentation for adding response content

bad_gateway(body \\ "", headers \\ [])

Create a “502 Bad Gateway” response.

See module documentation for adding response content

bad_request(body \\ "", headers \\ [])

Create a “400 Bad Request” response.

See module documentation for adding response content

client_error?(map)

The response indicates that the client sent an incorrect request.

https://tools.ietf.org/html/rfc7231#section-6.5

conflict(body \\ "", headers \\ [])

Create a “409 Conflict” response.

See module documentation for adding response content

continue(body \\ "", headers \\ [])

Create a “100 Continue” response.

See module documentation for adding response content

created(body \\ "", headers \\ [])

Create a “201 Created” response.

See module documentation for adding response content

expectation_failed(body \\ "", headers \\ [])

Create a “417 Expectation Failed” response.

See module documentation for adding response content

forbidden(body \\ "", headers \\ [])

Create a “403 Forbidden” response.

See module documentation for adding response content

found(body \\ "", headers \\ [])

Create a “302 Found” response.

See module documentation for adding response content

gateway_timeout(body \\ "", headers \\ [])

Create a “504 Gateway Timeout” response.

See module documentation for adding response content

gone(body \\ "", headers \\ [])

Create a “410 Gone” response.

See module documentation for adding response content

http_version_not_supported(body \\ "", headers \\ [])

Create a “505 HTTP Version Not Supported” response.

See module documentation for adding response content

informational?(map)

The response is marked as an interim response.

https://tools.ietf.org/html/rfc7231#section-6.2

internal_server_error(body \\ "", headers \\ [])

Create a “500 Internal Server Error” response.

See module documentation for adding response content

length_required(body \\ "", headers \\ [])

Create a “411 Length Required” response.

See module documentation for adding response content

method_not_allowed(body \\ "", headers \\ [])

Create a “405 Method Not Allowed” response.

See module documentation for adding response content

moved_permanently(body \\ "", headers \\ [])

Create a “301 Moved Permanently” response.

See module documentation for adding response content

multiple_choices(body \\ "", headers \\ [])

Create a “300 Multiple Choices” response.

See module documentation for adding response content

no_content(body \\ "", headers \\ [])

Create a “204 No Content” response.

See module documentation for adding response content

non-authoritative_information(body \\ "", headers \\ [])

Create a “203 Non-Authoritative Information” response.

See module documentation for adding response content

not_acceptable(body \\ "", headers \\ [])

Create a “406 Not Acceptable” response.

See module documentation for adding response content

not_found(body \\ "", headers \\ [])

Create a “404 Not Found” response.

See module documentation for adding response content

not_implemented(body \\ "", headers \\ [])

Create a “501 Not Implemented” response.

See module documentation for adding response content

not_modified(body \\ "", headers \\ [])

Create a “304 Not Modified” response.

See module documentation for adding response content

ok(body \\ "", headers \\ [])

Create a “200 OK” response.

See module documentation for adding response content

partial_content(body \\ "", headers \\ [])

Create a “206 Partial Content” response.

See module documentation for adding response content

payload_too_large(body \\ "", headers \\ [])

Create a “413 Payload Too Large” response.

See module documentation for adding response content

payment_required(body \\ "", headers \\ [])

Create a “402 Payment Required” response.

See module documentation for adding response content

precondition_failed(body \\ "", headers \\ [])

Create a “412 Precondition Failed” response.

See module documentation for adding response content

proxy_authentication_required(body \\ "", headers \\ [])

Create a “407 Proxy Authentication Required” response.

See module documentation for adding response content

range_not_satisfiable(body \\ "", headers \\ [])

Create a “416 Range Not Satisfiable” response.

See module documentation for adding response content

redirect?(map)

The response indicates that further action needs to be taken by the client.

https://tools.ietf.org/html/rfc7231#section-6.4

request_timeout(body \\ "", headers \\ [])

Create a “408 Request Timeout” response.

See module documentation for adding response content

reset_content(body \\ "", headers \\ [])

Create a “205 Reset Content” response.

See module documentation for adding response content

see_other(body \\ "", headers \\ [])

Create a “303 See Other” response.

See module documentation for adding response content

server_error?(map)

The response indicates that the server is incapable of acting upon the request.

https://tools.ietf.org/html/rfc7231#section-6.6

service_unavailable(body \\ "", headers \\ [])

Create a “503 Service Unavailable” response.

See module documentation for adding response content

success?(map)

The response indicates that client request was received, understood, and accepted.

https://tools.ietf.org/html/rfc7231#section-6.3

switching_protocols(body \\ "", headers \\ [])

Create a “101 Switching Protocols” response.

See module documentation for adding response content

temporary_redirect(body \\ "", headers \\ [])

Create a “307 Temporary Redirect” response.

See module documentation for adding response content

unauthorized(body \\ "", headers \\ [])

Create a “401 Unauthorized” response.

See module documentation for adding response content

unsupported_media_type(body \\ "", headers \\ [])

Create a “415 Unsupported Media Type” response.

See module documentation for adding response content

upgrade_required(body \\ "", headers \\ [])

Create a “426 Upgrade Required” response.

See module documentation for adding response content

uri_too_long(body \\ "", headers \\ [])

Create a “414 URI Too Long” response.

See module documentation for adding response content

use_proxy(body \\ "", headers \\ [])

Create a “305 Use Proxy” response.

See module documentation for adding response content