Packages

A simple and easy to use API created on top of the Mist web server

Current section

Files

Jump to
howdy src howdy@context.erl
Raw

src/howdy@context.erl

-module(howdy@context).
-compile(no_auto_import).
-export([new/3, is_authenticated/1]).
-export_type([context/1]).
-type context(HZF) :: {context,
list(howdy@url_parser:url_segment()),
gleam@http@request:request(bitstring()),
gleam@option:option(howdy@context@user:user()),
HZF}.
-spec new(
list(howdy@url_parser:url_segment()),
gleam@http@request:request(bitstring()),
HZO
) -> context(HZO).
new(Url, Request, Config) ->
{context, Url, Request, none, Config}.
-spec is_authenticated(context(any())) -> boolean().
is_authenticated(Context) ->
case erlang:element(4, Context) of
{some, _@1} ->
true;
none ->
false
end.