View Source KratosPlug.Config (kratos_plug v0.1.0)
Module for configuration. KratosPlug.Config type is compatible with Plug.opts().
keys
Keys
:kratos_adapterA module that implements theKratosPlug.KratosClientbehaviour.:kratos_base_urlA base URL for kratos. A base URL includes protocol, host, and port only.:tesla_adapterA module that implements theTesla.Adapterbehaviour.
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 options() :: [runtime_opt() | opt()]
@type value() :: any()
Link to this section Functions
@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}
]
@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}
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}
]