Packages

Elixir utils.

Retired package: Deprecated - Use instead antl_utils_* packages

Current section

Files

Jump to
antl_utils lib absinthe plug.ex
Raw

lib/absinthe/plug.ex

if Code.ensure_loaded?(Absinthe) do
defmodule AntlUtils.Absinthe.Plug do
@moduledoc """
Documentation for AntlAbsinthe.Plug
"""
@doc """
Assigns multiple **context** keys and values in the connection.
## Examples
iex> conn.private.absinthe.context[:my_plug_hello]
nil
iex> conn = put_context(conn, my_plug_hello: :world)
iex> conn.private.absinthe.context[:my_plug_hello]
:world
"""
@spec put_context(Plug.Conn.t(), Keyword.t()) :: Plug.Conn.t()
def put_context(%Plug.Conn{private: %{absinthe: %{context: context}}} = conn, keywords)
when is_list(keywords) do
context = Enum.into(keywords, context)
Absinthe.Plug.put_options(conn, context: context)
end
def put_context(conn, keywords) when is_list(keywords) do
context = Enum.into(keywords, %{})
Absinthe.Plug.put_options(conn, context: context)
end
end
end