raxx v1.1.0 Raxx.Request

HTTP requests to a Raxx application are encapsulated in a Raxx.Request struct.

A request has all the properties of the url it was sent to. In addition it has optional content, in the body. As well as a variable number of headers that contain meta data.

Where appropriate URI properties are named from this definition.

scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]

from wikipedia

The contents are itemised below:

schemehttp or https, depending on the transport used.
authorityThe location of the hosting server, as a binary. e.g. www.example.com. Plus an optional port number, separated from the hostname by a colon
methodThe HTTP request method, such as :GET or :POST, as an atom. This cannot ever be nil. It is always uppercase.
pathThe remainder of the request URL's “path”, split into segments. It designates the virtual “location” of the request's target within the application. This may be an empty array, if the requested URL targets the application root.
raw_pathThe request URL's "path"
querythe URL query string.
headersThe headers from the HTTP request as a proplist of strings. Note all headers will be downcased, e.g. [{"content-type", "text/plain"}]
bodyThe body content sent with the request

Link to this section Summary

Types

Method to indicate the desired action to be performed on the identified resource.

Scheme describing protocol used.

t()

Elixir representation for an HTTP request.

Functions

Return the host value for the request.

Return the port number used for the request.

Returns an URI struct corresponding to the url used in the provided request.

Link to this section Types

Link to this type

method()

method() :: atom()

Method to indicate the desired action to be performed on the identified resource.

Link to this type

scheme()

scheme() :: :http | :https

Scheme describing protocol used.

Link to this type

t()

t() :: %Raxx.Request{
  authority: binary(),
  body: Raxx.body(),
  headers: Raxx.headers(),
  method: method(),
  path: [binary()],
  query: binary() | nil,
  raw_path: binary(),
  scheme: scheme()
}

Elixir representation for an HTTP request.

Link to this section Functions

Return the host value for the request.

The Raxx.Request.t/0 struct contains authority field, which may contain the port number. This function returns the host value which won't include the port number.

Link to this function

port(request, default_ports \\ %{http: 80, https: 443})

port(t(), %{optional(atom()) => :inet.port_number()}) :: :inet.port_number()

Return the port number used for the request.

If no port number is explicitly specified in the request url, the default one for the scheme is used.

Link to this function

uri(request)

uri(t()) :: URI.t()

Returns an URI struct corresponding to the url used in the provided request.

NOTE: the userinfo field of the URI will always be nil, even if there is Authorization header basic auth information contained in the request.

The fragment will also be nil, as the servers don't have access to it.