module Mig.Html
(
Get (..)
, Post (..)
, Put (..)
, Delete (..)
, Patch (..)
, Options (..)
, module X
) where
import Mig.Common as X
import Mig.Internal.Types (toMethod)
import Network.HTTP.Types.Method
newtype Get m a = Get (m a)
instance (Monad m, ToHtmlResp a) => ToServer (Get m a) where
type ServerMonad (Get m a) = m
toServer :: Get m a -> Server (ServerMonad (Get m a))
toServer (Get m a
act) = forall (m :: * -> *). Monad m => Method -> m Resp -> Server m
toMethod Method
methodGet (forall a. ToHtmlResp a => a -> Resp
toHtmlResp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
act)
newtype Post m a = Post (m a)
instance (Monad m, ToHtmlResp a) => ToServer (Post m a) where
type ServerMonad (Post m a) = m
toServer :: Post m a -> Server (ServerMonad (Post m a))
toServer (Post m a
act) = forall (m :: * -> *). Monad m => Method -> m Resp -> Server m
toMethod Method
methodPost (forall a. ToHtmlResp a => a -> Resp
toHtmlResp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
act)
newtype Put m a = Put (m a)
instance (Monad m, ToHtmlResp a) => ToServer (Put m a) where
type ServerMonad (Put m a) = m
toServer :: Put m a -> Server (ServerMonad (Put m a))
toServer (Put m a
act) = forall (m :: * -> *). Monad m => Method -> m Resp -> Server m
toMethod Method
methodPut (forall a. ToHtmlResp a => a -> Resp
toHtmlResp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
act)
newtype Delete m a = Delete (m a)
instance (Monad m, ToHtmlResp a) => ToServer (Delete m a) where
type ServerMonad (Delete m a) = m
toServer :: Delete m a -> Server (ServerMonad (Delete m a))
toServer (Delete m a
act) = forall (m :: * -> *). Monad m => Method -> m Resp -> Server m
toMethod Method
methodDelete (forall a. ToHtmlResp a => a -> Resp
toHtmlResp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
act)
newtype Patch m a = Patch (m a)
instance (Monad m, ToHtmlResp a) => ToServer (Patch m a) where
type ServerMonad (Patch m a) = m
toServer :: Patch m a -> Server (ServerMonad (Patch m a))
toServer (Patch m a
act) = forall (m :: * -> *). Monad m => Method -> m Resp -> Server m
toMethod Method
methodPatch (forall a. ToHtmlResp a => a -> Resp
toHtmlResp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
act)
newtype Options m a = Options (m a)
instance (Monad m, ToHtmlResp a) => ToServer (Options m a) where
type ServerMonad (Options m a) = m
toServer :: Options m a -> Server (ServerMonad (Options m a))
toServer (Options m a
act) = forall (m :: * -> *). Monad m => Method -> m Resp -> Server m
toMethod Method
methodOptions (forall a. ToHtmlResp a => a -> Resp
toHtmlResp forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
act)