-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Composable, type-safe library to build HTTP API servers -- -- WebGear is a library to for building composable, type-safe HTTP API -- servers. WebGear focuses on good documentation and usability. See the -- documentation of WebGear module to get started. @package webgear-server @version 1.0.3 -- | Server implementation of WebGear handlers module WebGear.Server.Handler -- | An arrow implementing a WebGear server. -- -- It can be thought of equivalent to the function arrow a -> m -- b where m is a monad. It also supports routing and -- possibly failing the computation when the route does not match. newtype ServerHandler m a b ServerHandler :: ((a, RoutePath) -> m (Either RouteMismatch b, RoutePath)) -> ServerHandler m a b [unServerHandler] :: ServerHandler m a b -> (a, RoutePath) -> m (Either RouteMismatch b, RoutePath) -- | Parts of the request path used by the routing machinery newtype RoutePath RoutePath :: [Text] -> RoutePath -- | Run a ServerHandler to produce a result or a route mismatch error. runServerHandler :: Monad m => ServerHandler m a b -> RoutePath -> a -> m (Either RouteMismatch b) -- | Convert a ServerHandler to a WAI application toApplication :: ServerHandler IO (Linked '[] Request) Response -> Application -- | Transform a ServerHandler running in one monad to another -- monad. -- -- This is useful in cases where the server is running in a custom monad -- but you would like to convert it to a WAI application using -- toApplication. -- -- Example usage with a ReaderT monad stack: -- --
--   toApplication (transform f server)
--     where
--       server :: ServerHandler (ReaderT r IO) (Linked '[] Request) Response
--       server = ....
--   
--       f :: ReaderT r IO a -> IO a
--       f action = runReaderT action r
--   
transform :: (forall x. m x -> n x) -> ServerHandler m a b -> ServerHandler n a b instance GHC.Base.Monad m => Control.Category.Category (WebGear.Server.Handler.ServerHandler m) instance GHC.Base.Monad m => Control.Arrow.Arrow (WebGear.Server.Handler.ServerHandler m) instance GHC.Base.Monad m => Control.Arrow.ArrowZero (WebGear.Server.Handler.ServerHandler m) instance GHC.Base.Monad m => Control.Arrow.ArrowPlus (WebGear.Server.Handler.ServerHandler m) instance GHC.Base.Monad m => Control.Arrow.ArrowChoice (WebGear.Server.Handler.ServerHandler m) instance GHC.Base.Monad m => Control.Arrow.Operations.ArrowError WebGear.Core.Handler.RouteMismatch (WebGear.Server.Handler.ServerHandler m) instance GHC.Base.Monad m => WebGear.Core.Handler.Handler (WebGear.Server.Handler.ServerHandler m) m -- | Server implementation of the BasicAuth' trait. module WebGear.Server.Trait.Auth.Basic instance (GHC.Base.Monad m, WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.Common.AuthorizationHeader scheme) WebGear.Core.Request.Request) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.Basic.BasicAuth' 'WebGear.Core.Modifiers.Required scheme m e a) WebGear.Core.Request.Request instance (GHC.Base.Monad m, WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.Common.AuthorizationHeader scheme) WebGear.Core.Request.Request) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.Basic.BasicAuth' 'WebGear.Core.Modifiers.Optional scheme m e a) WebGear.Core.Request.Request -- | Server implementation of the JWTAuth' trait. module WebGear.Server.Trait.Auth.JWT instance (Control.Monad.Time.MonadTime m, WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.Common.AuthorizationHeader scheme) WebGear.Core.Request.Request) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.JWT.JWTAuth' 'WebGear.Core.Modifiers.Required scheme m e a) WebGear.Core.Request.Request instance (Control.Monad.Time.MonadTime m, WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.Common.AuthorizationHeader scheme) WebGear.Core.Request.Request) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Auth.JWT.JWTAuth' 'WebGear.Core.Modifiers.Optional scheme m e a) WebGear.Core.Request.Request -- | Server implementation of the Body trait. module WebGear.Server.Trait.Body instance (Control.Monad.IO.Class.MonadIO m, Data.ByteString.Conversion.From.FromByteString val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Body.Body val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, Data.ByteString.Conversion.To.ToByteString val) => WebGear.Core.Trait.Set (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Body.Body val) WebGear.Core.Response.Response instance (Control.Monad.IO.Class.MonadIO m, Data.Aeson.Types.FromJSON.FromJSON val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Body.JSONBody val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, Data.Aeson.Types.ToJSON.ToJSON val) => WebGear.Core.Trait.Set (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Body.JSONBody val) WebGear.Core.Response.Response -- | Server implementation of the Header trait. module WebGear.Server.Trait.Header instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Header.Header 'WebGear.Core.Modifiers.Required 'WebGear.Core.Modifiers.Strict name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Header.Header 'WebGear.Core.Modifiers.Optional 'WebGear.Core.Modifiers.Strict name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Header.Header 'WebGear.Core.Modifiers.Required 'WebGear.Core.Modifiers.Lenient name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Header.Header 'WebGear.Core.Modifiers.Optional 'WebGear.Core.Modifiers.Lenient name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Data.ByteString.Conversion.To.ToByteString val) => WebGear.Core.Trait.Set (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Header.Header 'WebGear.Core.Modifiers.Required 'WebGear.Core.Modifiers.Strict name val) WebGear.Core.Response.Response instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Data.ByteString.Conversion.To.ToByteString val) => WebGear.Core.Trait.Set (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Header.Header 'WebGear.Core.Modifiers.Optional 'WebGear.Core.Modifiers.Strict name val) WebGear.Core.Response.Response -- | Server implementation of the Method trait. module WebGear.Server.Trait.Method instance GHC.Base.Monad m => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) WebGear.Core.Trait.Method.Method WebGear.Core.Request.Request -- | Server implementation of the path traits. module WebGear.Server.Trait.Path instance GHC.Base.Monad m => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) WebGear.Core.Trait.Path.Path WebGear.Core.Request.Request instance (GHC.Base.Monad m, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.Path.PathVar tag val) WebGear.Core.Request.Request instance GHC.Base.Monad m => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) WebGear.Core.Trait.Path.PathEnd WebGear.Core.Request.Request -- | Server implementation of the QueryParam trait. module WebGear.Server.Trait.QueryParam instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.QueryParam.QueryParam 'WebGear.Core.Modifiers.Required 'WebGear.Core.Modifiers.Strict name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.QueryParam.QueryParam 'WebGear.Core.Modifiers.Optional 'WebGear.Core.Modifiers.Strict name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.QueryParam.QueryParam 'WebGear.Core.Modifiers.Required 'WebGear.Core.Modifiers.Lenient name val) WebGear.Core.Request.Request instance (GHC.Base.Monad m, GHC.TypeLits.KnownSymbol name, Web.Internal.HttpApiData.FromHttpApiData val) => WebGear.Core.Trait.Get (WebGear.Server.Handler.ServerHandler m) (WebGear.Core.Trait.QueryParam.QueryParam 'WebGear.Core.Modifiers.Optional 'WebGear.Core.Modifiers.Lenient name val) WebGear.Core.Request.Request -- | Server implementation of the Status trait. module WebGear.Server.Trait.Status instance GHC.Base.Monad m => WebGear.Core.Trait.Set (WebGear.Server.Handler.ServerHandler m) WebGear.Core.Trait.Status.Status WebGear.Core.Response.Response -- | Server implementation of all traits supported by WebGear. -- -- This modules only exports orphan instances imported from other -- modules. Hence the haddock documentation will be empty. module WebGear.Server.Traits -- | Main module for WebGear server. -- -- Import this module to get all required types and functions to build a -- WebGear server. Alternatively, import individual modules under -- WebGear.Server. -- -- Typical usage to implement a server is: -- --
--   import WebGear.Server
--   import Network.Wai (Application)
--   import qualified Network.Wai.Handler.Warp as Warp
--   
--   -- | A monad stack for you application
--   type App a = ....
--   
--   -- | Convert the App monad to IO
--   runApp :: App a -> IO a
--   runApp = ....
--   
--   -- | Handler for the server
--   myHandler :: Handler h App => RequestHandler h '[]
--   myHandler = ....
--   
--   app :: Application
--   app = toApplication (transform runApp myHandler)
--   
--   main :: IO ()
--   main = Warp.run port app
--   
module WebGear.Server