mig-0.2.1.0: Build lightweight and composable servers
Safe HaskellSafe-Inferred
LanguageGHC2021

Mig.Core.Class.Server

Description

To server class

Synopsis

Documentation

(/.) :: ToServer a => Path -> a -> Server (MonadOf a) infixr 4 Source #

Constructs server which can handle given path. Example:

"api/v1/get/info" /. handleInfo

For captures we use wild-cards:

"api/v1/get/info/*" /. handleInfo

And handle info has capture argument:

handleInfo :: Capture "nameA" -> Get IO (Resp Json value)

The name for the capture is derived from the type signature of the route handler. Note that if capture is in the last position of the path we can omit wild cards. The proper amount of captures will be derived from the type signature of the handler.

class ToServer a where Source #

Values that can be converted to server

Methods

toServer :: a -> Server (MonadOf a) Source #

Convert value to server

Instances

Instances details
ToRoute a => ToServer a Source # 
Instance details

Defined in Mig.Core.Class.Server

Methods

toServer :: a -> Server (MonadOf a) Source #

ToServer (Server m) Source # 
Instance details

Defined in Mig.Core.Class.Server

Methods

toServer :: Server m -> Server (MonadOf (Server m)) Source #

ToServer a => ToServer [a] Source # 
Instance details

Defined in Mig.Core.Class.Server

Methods

toServer :: [a] -> Server (MonadOf [a]) Source #

class Monad m => HasServer m where Source #

Class contains types which can be converted to IO-based server to run as with WAI-interface.

We can run plain IO-servers and ReaderT over IO based servers. Readers can be wrapped in newtypes. In that case we can derive automatically HasServer instance.

Associated Types

type ServerResult m :: Type Source #

Instances

Instances details
HasServer IO Source # 
Instance details

Defined in Mig.Core.Class.Server

Associated Types

type ServerResult IO Source #

HasServer (ReaderT env IO) Source # 
Instance details

Defined in Mig.Core.Class.Server

Associated Types

type ServerResult (ReaderT env IO) Source #

HasServer (ReaderT env (ExceptT Text IO)) Source # 
Instance details

Defined in Mig.Core.Class.Server

Associated Types

type ServerResult (ReaderT env (ExceptT Text IO)) Source #

hoistServer :: (forall a. m a -> n a) -> Server m -> Server n Source #

Map internal monad of the server

fromReader :: env -> Server (ReaderT env IO) -> Server IO Source #

Render reader server to IO-based server

fromReaderExcept :: forall env. env -> Server (ReaderT env (ExceptT Text IO)) -> Server IO Source #

Render reader with expetT server to IO-based server