View Source Orbit.Request (Orbit v0.3.0)

Encapsulate the request-response cycle.

Analogous to %Plug.Conn{}.

Request Fields

  • client_cert - an Orbit.ClientCertificate for the client TLS certificate, if provided
  • params - combined request parameters from the URI and query params
    • bare query strings (e.g. "?foo") are assigned to the "_query" key
  • uri - the parsed request URI struct

Response Fields

  • body - the response body; may be an iolist or a stream
  • halted? - if the current response pipeline should be stopped prematurely
  • meta - the response meta field; its meaning depends on the status code
  • status - the response status code, may be an integer or an atom (see Orbit.Status)
  • sent? - if the response has been transmitted back to the client

Application Fields

  • assigns - a generic map of application-defined data to be manipulated and rendered
  • private - a generic map of library-defined data that should not be accessed by end-users

Summary

Status Functions

Responds with a :bad_request status.

Responds with a :certificate_not_authorized status.

Responds with a :certificate_not_valid status.

Responds with a :cgi_error status.

Responds with a :client_certificate_required status.

Responds with a :gone status.

Responds with a :input status.

Responds with a :not_found status.

Responds with a :permanent_failure status.

Responds with a :proxy_error status.

Responds with a :proxy_request_refused status.

Responds with a :redirect_permanent status.

Responds with a :redirect_temporary status.

Responds with a :sensitive_input status.

Responds with a :server_unavailable status.

Responds with a :slow_down status.

Responds with a :success status.

Responds with a :temporary_failure status.

Functions

Sets multiple assigns on the request.

Sets a single assign on the request.

Stops the request pipeline from further execution.

Puts the body for a successful response.

Sets a single private value on the request.

Puts the status and metadata for a response.

Status Functions

Link to this function

bad_request(req, message \\ nil)

View Source

Responds with a :bad_request status.

Link to this function

certificate_not_authorized(req, message \\ nil)

View Source

Responds with a :certificate_not_authorized status.

Link to this function

certificate_not_valid(req, message \\ nil)

View Source

Responds with a :certificate_not_valid status.

Link to this function

cgi_error(req, message \\ nil)

View Source

Responds with a :cgi_error status.

Link to this function

client_certificate_required(req, message \\ nil)

View Source

Responds with a :client_certificate_required status.

Link to this function

gone(req, message \\ nil)

View Source

Responds with a :gone status.

Link to this function

input(req, prompt \\ nil)

View Source

Responds with a :input status.

Link to this function

not_found(req, message \\ nil)

View Source

Responds with a :not_found status.

Link to this function

permanent_failure(req, message \\ nil)

View Source

Responds with a :permanent_failure status.

Link to this function

proxy_error(req, message \\ nil)

View Source

Responds with a :proxy_error status.

Link to this function

proxy_request_refused(req, message \\ nil)

View Source

Responds with a :proxy_request_refused status.

Link to this function

redirect_permanent(req, uri \\ nil)

View Source

Responds with a :redirect_permanent status.

Link to this function

redirect_temporary(req, uri \\ nil)

View Source

Responds with a :redirect_temporary status.

Link to this function

sensitive_input(req, prompt \\ nil)

View Source

Responds with a :sensitive_input status.

Link to this function

server_unavailable(req, message \\ nil)

View Source

Responds with a :server_unavailable status.

Link to this function

slow_down(req, message \\ nil)

View Source

Responds with a :slow_down status.

Link to this function

success(req, mime_type \\ nil)

View Source

Responds with a :success status.

Link to this function

temporary_failure(req, message \\ nil)

View Source

Responds with a :temporary_failure status.

Types

@type t() :: %Orbit.Request{
  assigns: %{required(atom()) => any()},
  body:
    IO.chardata()
    | %Stream{accs: term(), done: term(), enum: term(), funs: term()}
    | nil,
  client_cert: any(),
  halted?: boolean(),
  meta: IO.chardata() | nil,
  params: %{required(String.t()) => String.t()},
  private: %{optional(atom()) => any()},
  sent?: boolean(),
  status: Orbit.Status.t(),
  uri: %URI{
    authority: term(),
    fragment: term(),
    host: term(),
    path: term(),
    port: term(),
    query: term(),
    scheme: term(),
    userinfo: term()
  }
}

Functions

Sets multiple assigns on the request.

Sets a single assign on the request.

Stops the request pipeline from further execution.

Puts the body for a successful response.

The MIME type is specified via the meta argument of put_status/3.

Link to this function

put_private(req, key, value)

View Source

Sets a single private value on the request.

Link to this function

put_status(req, status, meta \\ nil)

View Source

Puts the status and metadata for a response.

If the status code is non-successful, then the response body will be ignored and not sent to the client.

The status can be an integer or an atom. See Orbit.Status for a list of applicable status codes and convenience functions.