Packages
raxx
0.14.7
1.1.0
1.0.1
1.0.0
1.0.0-rc.3
1.0.0-rc.2
retired
1.0.0-rc.1
retired
1.0.0-rc.0
retired
0.18.1
0.18.0
0.17.6
0.17.5
0.17.4
0.17.3
0.17.2
0.17.1
0.17.0
0.16.1
0.16.0
retired
0.15.11
0.15.10
0.15.9
0.15.8
0.15.7
0.15.6
0.15.5
0.15.4
0.15.3
0.15.2
0.15.1
0.15.0
0.14.14
0.14.13
0.14.12
0.14.11
0.14.10
0.14.9
0.14.8
0.14.7
0.14.6
0.14.5
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.0
0.12.3
0.12.2
0.12.1
0.12.0
0.11.1
0.11.0
0.10.5
0.10.4
0.10.3
0.10.2
0.10.1
0.10.0
0.9.0
0.8.2
0.8.1
0.8.0
0.7.1
0.7.0
0.6.0
0.5.2
0.5.1
0.5.0
0.4.3
0.4.2
0.4.1
0.4.0
0.3.0
0.2.0
0.1.0
0.0.1
Interface for HTTP webservers, frameworks and clients.
Current section
Files
Jump to
Current section
Files
lib/raxx/response.ex
defmodule Raxx.Response do
@moduledoc """
HTTP responses from a Raxx application are encapsulated in a `Raxx.Response` struct.
The contents are itemised below:
| **status** | The HTTP status code for the response: `1xx, 2xx, 3xx, 4xx, 5xx` |
| **headers** | The response headers as a list: `[{"content-type", "text/plain"}` |
| **body** | The response body, by default an empty string. |
"""
@typedoc """
Integer code for server response type
"""
@type status_code :: integer
@typedoc """
Elixir representation for an HTTP response.
"""
@type t :: %__MODULE__{
status: status_code,
headers: Raxx.headers(),
body: Raxx.body()
}
@enforce_keys [:status, :headers, :body]
defstruct @enforce_keys
# DEBT I never used these, will they be missed?
# @doc """
# The response is marked as an interim response.
#
# https://tools.ietf.org/html/rfc7231#section-6.2
# """
# def informational?(%{status: code}), do: 100 <= code and code < 200
#
# @doc """
# The response indicates that client request was received, understood, and accepted.
#
# https://tools.ietf.org/html/rfc7231#section-6.3
# """
# def success?(%{status: code}), do: 200 <= code and code < 300
#
# @doc """
# The response indicates that further action needs to be taken by the client.
#
# https://tools.ietf.org/html/rfc7231#section-6.4
# """
# def redirect?(%{status: code}), do: 300 <= code and code < 400
#
# @doc """
# The response indicates that the client sent an incorrect request.
#
# https://tools.ietf.org/html/rfc7231#section-6.5
# """
# def client_error?(%{status: code}), do: 400 <= code and code < 500
#
# @doc """
# The response indicates that the server is incapable of acting upon the request.
#
# https://tools.ietf.org/html/rfc7231#section-6.6
# """
# def server_error?(%{status: code}), do: 500 <= code and code < 600
end