View Source Unleash.Propagation.Plugs (Unleash v1.14.0)
Module that defines plugs to extract unleash context and feature flag overrides from headers of incoming HTTP requests and store them in the process dictionary.
The stored values will then be considered by the Unleash client when evaluating features.
This allows for client-driven Unleash behaviour across client-server interactions.
Summary
Functions
A generic Plug to extract an header value, transform it, and store it.
A Plug that extracts the unleash context from a request header and stores it in the
process dictionary under :unleash_context.
A Plug that extracts unleash overrides from a request header and stores them in the
process dictionary under :unleash_overrides.
Functions
@spec extract_header_and_store( Plug.Conn.t(), keyword() ) :: Plug.Conn.t()
A generic Plug to extract an header value, transform it, and store it.
It's unlikely you'll need to use this directly, and you should simply plug
extract_unleash_context/2 and extract_unleash_overrides/2 in your pipelines instead,
but if you know what you're doing and you need custom behaviour, feel free to use this.
@spec extract_unleash_context( Plug.Conn.t(), keyword() ) :: Plug.Conn.t()
A Plug that extracts the unleash context from a request header and stores it in the
process dictionary under :unleash_context.
By default it uses x-unleash-context header, but you can specify the header_name option
to use a different one:
plug :extract_unleash_context, header_name: "my-custom-header"
@spec extract_unleash_overrides( Plug.Conn.t(), keyword() ) :: Plug.Conn.t()
A Plug that extracts unleash overrides from a request header and stores them in the
process dictionary under :unleash_overrides.
By default it uses x-unleash-overrides header, but you can specify the header_name option
to use a different one:
plug :extract_unleash_overrides, header_name: "my-custom-header"