View Source Orbit.Request (Orbit v0.1.0)

Encapsulate the request-response cycle.

Analgous to %Plug.Conn{}.

request-fields

Request Fields

  • client_cert - the client TLS certificate
  • params - combined request parameters from the URI and query params
  • uri - the parsed request URI

response-fields

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, meaning depends on the status code
  • status - the response status code, may be an integer or an atom (see below)
  • sent? - if the response has been transmitted back to the client

other-fields

Other 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

Link to this section Summary

Functions

Sets multiple assigns on the request.

Sets a single assign on the request.

Stops the request pipeline from further execution.

Puts the body and MIME type for a successful response.

Sets a single private value on the request.

Puts the status and metadata for a response.

Link to this section 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()
  }
}

Link to this section Functions

Sets multiple assigns on the request.

Sets a single assign on the request.

Stops the request pipeline from further execution.

Link to this function

put_body(req, body, mime_type \\ nil)

View Source

Puts the body and MIME type for a successful response.

The MIME type is optional. If unspecified, clients will default to "text/gemini; charset=utf-8".

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.