View Source CozyOSS.ApiRequest (cozy_oss v0.1.3)

Converts %ApiSpec{} to a %ApiRequest{}.

Link to this section Summary

Types

Optional request body.

Request headers.

Request method.

Request path.

Optional request query.

Request scheme.

t()

Functions

Bulid a struct %CozyOSS.ApiRequest{} from %CozyOSS.Config{} and %CozyOSS.ApiSpec{}.

Converts a request to a signed URL.

Link to this section Types

@type body() :: iodata() | nil

Optional request body.

@type headers() :: %{
  optional(header_name :: String.t()) => header_value :: String.t()
}

Request headers.

@type meta() :: %{optional(atom()) => term()}
@type method() :: String.t()

Request method.

@type path() :: String.t()

Request path.

@type private() :: %{optional(atom()) => term()}
@type query() :: %{
  optional(query_name :: String.t()) =>
    query_value :: boolean() | number() | String.t()
}

Optional request query.

@type scheme() :: :https

Request scheme.

@type t() :: %CozyOSS.ApiRequest{
  body: body(),
  headers: headers(),
  host: String.t() | nil,
  meta: meta(),
  method: method(),
  path: String.t(),
  port: :inet.port_number(),
  private: private(),
  query: query(),
  scheme: scheme()
}

Link to this section Functions

Link to this function

build!(config, api_spec, opts)

View Source
@spec build!(CozyOSS.Config.t(), CozyOSS.ApiSpec.t(), keyword()) :: t()

Bulid a struct %CozyOSS.ApiRequest{} from %CozyOSS.Config{} and %CozyOSS.ApiSpec{}.

This function has built-in signing support, and it's controlled by option :sign_by:

  • sign_by: :header - add signatures to request headers.
  • sign_by: :url - add signatures to URL.

When using sign_by: :url, an extra option :expiration_in_seconds is supported. The default value is 900.

@spec to_url!(t()) :: binary()

Converts a request to a signed URL.