{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}

module Web.Minion.Examples.HelloWorld (app) where

import Web.Minion

app :: ApplicationM IO
app :: ApplicationM IO
app = forall (m :: * -> *) i.
(MonadIO m, MonadCatch m) =>
Router' i Void m -> ApplicationM m
serve @IO Router' Void Void IO
api

api :: Router Void IO
api :: Router' Void Void IO
api =
  Router' Void Void IO -> Router' Void Void IO
"api"
    (Router' Void Void IO -> Router' Void Void IO)
-> Router' Void Void IO -> Router' Void Void IO
forall i ts (r :: * -> *).
(Router' i ts r -> Router' i ts r)
-> Router' i ts r -> Router' i ts r
/> [ Router' Void Void IO -> Router' Void Void IO
"about" (Router' Void Void IO -> Router' Void Void IO)
-> Router' Void Void IO -> Router' Void Void IO
forall i ts (r :: * -> *).
(Router' i ts r -> Router' i ts r)
-> Router' i ts r -> Router' i ts r
/> forall o (m :: * -> *) ts i (st :: [*]).
(HandleArgs ts st m, ToResponse m (RespBody '[PlainText] o),
 Introspection i 'Response (RespBody '[PlainText] o)) =>
Method -> (DelayedArgs st ~> m o) -> Router' i ts m
handlePlainText @String Method
GET (String -> IO String
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"Hello-World Minion server")
       , Router' Void Void IO -> Router' Void Void IO
"hello" (Router' Void Void IO -> Router' Void Void IO)
-> Router' Void Void IO -> Router' Void Void IO
forall i ts (r :: * -> *).
(Router' i ts r -> Router' i ts r)
-> Router' i ts r -> Router' i ts r
/> forall b (m :: * -> *) i ts.
(FromHttpApiData b, Introspection i 'Capture b, MonadThrow m) =>
Text -> ValueCombinator i (WithPiece b) ts m
capture @String Text
"name" ValueCombinator Void (WithPiece String) Void IO
-> ValueCombinator Void (WithPiece String) Void IO
forall i ts' (r :: * -> *) ts.
(Router' i ts' r -> Router' i ts r)
-> Router' i ts' r -> Router' i ts r
.> forall o (m :: * -> *) ts i (st :: [*]).
(HandleArgs ts st m, ToResponse m (RespBody '[PlainText] o),
 Introspection i 'Response (RespBody '[PlainText] o)) =>
Method -> (DelayedArgs st ~> m o) -> Router' i ts m
handlePlainText @String Method
GET (\String
name -> String -> IO String
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> IO String) -> String -> IO String
forall a b. (a -> b) -> a -> b
$ String
"Hello, " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
name String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"!")
       ]