module Mig.Html.IO
(
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 a = Get (IO a)
instance (ToHtmlResp a) => ToServer (Get a) where
type ServerMonad (Get a) = IO
toServer :: Get a -> Server (ServerMonad (Get a))
toServer (Get IO 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
<$> IO a
act)
newtype Post a = Post (IO a)
instance (ToHtmlResp a) => ToServer (Post a) where
type ServerMonad (Post a) = IO
toServer :: Post a -> Server (ServerMonad (Post a))
toServer (Post IO 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
<$> IO a
act)
newtype Put a = Put (IO a)
instance (ToHtmlResp a) => ToServer (Put a) where
type ServerMonad (Put a) = IO
toServer :: Put a -> Server (ServerMonad (Put a))
toServer (Put IO 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
<$> IO a
act)
newtype Delete a = Delete (IO a)
instance (ToHtmlResp a) => ToServer (Delete a) where
type ServerMonad (Delete a) = IO
toServer :: Delete a -> Server (ServerMonad (Delete a))
toServer (Delete IO 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
<$> IO a
act)
newtype Patch a = Patch (IO a)
instance (ToHtmlResp a) => ToServer (Patch a) where
type ServerMonad (Patch a) = IO
toServer :: Patch a -> Server (ServerMonad (Patch a))
toServer (Patch IO 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
<$> IO a
act)
newtype Options a = Options (IO a)
instance (ToHtmlResp a) => ToServer (Options a) where
type ServerMonad (Options a) = IO
toServer :: Options a -> Server (ServerMonad (Options a))
toServer (Options IO 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
<$> IO a
act)