View Source KratosPlug.Config (kratos_plug v0.1.0)

Module for configuration. KratosPlug.Config type is compatible with Plug.opts().

keys

Keys

  • :kratos_adapter A module that implements the KratosPlug.KratosClient behaviour.
  • :kratos_base_url A base URL for kratos. A base URL includes protocol, host, and port only.
  • :tesla_adapter A module that implements the Tesla.Adapter behaviour.

Link to this section Summary

Functions

Returns a Keyword list of default options.

This function allows for the graceful evaulation of runtime options.

This function allows for the safe merger of default and implementor options.

Link to this section Types

@type key() :: :kratos_adapter | :kratos_base_url | :tesla_adapter | atom()
@type opt() :: {key(), value()}
@type options() :: [runtime_opt() | opt()]
@type runtime_opt() :: {any(), (... -> any())}
@type value() :: any()

Link to this section Functions

Link to this function

default_opts()

View Source (since 0.1.0)
@spec default_opts() :: Options.t()

Returns a Keyword list of default options.

example

Example

  iex> default_opts()
  [
    {:kratos_adapter, KratosPlug.KratosClient.TeslaAdapter},
    {:proxy_adapter, nil},
    {:kratos_base_url, nil},
    {:proxy_base_url, nil},
    {:tesla_adapter, Tesla.Adapter.Hackney}
  ]
Link to this function

eval_opts(opts)

View Source (since 0.1.0)
@spec eval_opts(Options.t()) :: Options.t()

This function allows for the graceful evaulation of runtime options.

example-with-keyword-list

Example with Keyword list

  iex> eval_opts([{:foo, fn -> :bar end}, {:bar, :baz}])
  [{:foo, :bar}, {:bar, :baz}]

example-with-unsupported-type

Example with unsupported type

  iex> eval_opts(%{foo: fn -> :bar end, bar: :baz})
  %{foo: fn -> :bar end, bar: :baz}
Link to this function

merge_defaults(opts)

View Source (since 0.1.0)
@spec merge_defaults(Keyword.t()) :: Keyword.t()

This function allows for the safe merger of default and implementor options.

example

Example

  iex> merge_defaults([{:kratos_base_url, "http://kratos:80"}, {:non_standard, 0}])
  [
    {:kratos_adapter, KratosPlug.KratosClient.TeslaAdapter},
    {:proxy_adapter, KratosPlug.ProxyClient.TeslaAdapter},
    {:kratos_base_url, "http://kratos:80"},
    {:proxy_base_url, nil},
    {:non_standard, 0}
  ]