Contexts are used to pass values to combinators. (They are not meant
to be used to pass parameters to your handlers, i.e. they should not replace
any custom ReaderT-monad-stack that you're using
with hoistServer.) If you don't use combinators that
require any context entries, you can just use serve as always.
If you are using combinators that require a non-empty Context you have to
use serveWithContext and pass it a Context that contains all
the values your combinators need. A Context is essentially a heterogeneous
list and accessing the elements is being done by type (see getContextEntry).
The parameter of the type Context is a type-level list reflecting the types
of the contained context entries. To create a Context with entries, use the
operator (:.):
:type True :. () :. EmptyContextTrue :. () :. EmptyContext :: Context '[Bool, ()]
Constructors
EmptyContext :: Context '[](:.) :: x -> Context xs -> Context (x ': xs)infixr 5
Instances4Eq, Show
Eq (Context '[])Defined in servant-server-0.20.2 · Servant.Server.Internal.Context(Eq a, Eq (Context as)) => Eq (Context (a ': as))Defined in servant-server-0.20.2 · Servant.Server.Internal.ContextShow (Context '[])Defined in servant-server-0.20.2 · Servant.Server.Internal.Context(Show a, Show (Context as)) => Show (Context (a ': as))Defined in servant-server-0.20.2 · Servant.Server.Internal.Context