View Source CharonAbsinthe.Config (CharonAbsinthe v0.2.0)

Config module for CharonAbsinthe.

Charon.Config.from_enum(
  ...,
  optional_modules: %{
    CharonAbsinthe => %{
      access_token_pipeline: MyApp.AccessTokenPipeline,
      refresh_token_pipeline: MyApp.RefreshTokenPipeline,
      auth_error_handler: &MyApp.Absinthe.auth_error_handler/2
    }
  }
)

The following options are supported:

  • :access_token_pipeline (required). A Plug that validates an access token (see readme).
  • :refresh_token_pipeline (required). A Plug that validates a refresh token (see readme).
  • :auth_error_handler (required). A function that takes an %Absinthe.Resolution{} struct and an error message, and returns the resolution struct.

Link to this section Summary

Functions

Build config struct from enumerable (useful for passing in application environment). Raises for missing mandatory keys and sets defaults for optional keys.

Link to this section Types

@type t() :: %CharonAbsinthe.Config{
  access_token_pipeline: module(),
  auth_error_handler:
    (Absinthe.Resolution.t(), String.t() -> Absinthe.Resolution.t()),
  refresh_token_pipeline: module()
}

Link to this section Functions

@spec from_enum(Enum.t()) :: t()

Build config struct from enumerable (useful for passing in application environment). Raises for missing mandatory keys and sets defaults for optional keys.