Gonex v0.1.0 Gonex.Controller View Source

This module contains functions for working with gon storage.

Link to this section Summary

Functions

Gets gon storage.

Gets the value from gon storage.

Merges given values into gon storage.

Puts given value into gon storage under specified key.

Link to this section Functions

Gets gon storage.

Examples

iex> get_gon(conn)
%{greeting: "Hello, World!"}
Link to this function

get_gon(conn, key, default \\ nil)

View Source
get_gon(Plug.Conn.t(), atom(), any()) :: any()

Gets the value from gon storage.

Examples

iex> get_gon(conn, :greeting)
"Hello, World!"
iex> get_gon(conn, :name)
nil
iex> get_gon(conn, :name, "Alice")
"Alice"
Link to this function

put_gon(conn, values)

View Source
put_gon(Plug.Conn.t(), Map.t() | Keyword.t()) :: Plug.Conn.t()

Merges given values into gon storage.

Examples

iex> get_gon(conn)
%{}
iex> put_gon(conn, %{greeting: "Hello, World!"})
iex> get_gon(conn)
%{greeting: "Hello, World!"}
iex> put_gon(conn, greeting: "Hello!")
iex> get_gon(conn)
%{greeting: "Hello!"}
Link to this function

put_gon(conn, key, value)

View Source
put_gon(Plug.Conn.t(), atom(), any()) :: Plug.Conn.t()

Puts given value into gon storage under specified key.

Examples

iex> get_gon(conn)
%{}
iex> put_gon(conn, :greeting, "Hello, World!")
iex> get_gon(conn)
%{greeting: "Hello, World!"}