matebeamter/src/API.hs

60 lines
1.4 KiB
Haskell
Raw Normal View History

2019-09-08 00:37:50 +00:00
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
2019-09-17 19:29:56 +00:00
{-# LANGUAGE PackageImports #-}
2019-09-08 00:37:50 +00:00
module API where
import Servant.API
2019-09-16 07:44:46 +00:00
import Servant.Links
2019-09-08 00:37:50 +00:00
import Servant.RawM
import Servant.HTML.Blaze
2019-09-16 07:44:46 +00:00
import Data.Proxy
2019-10-04 07:04:23 +00:00
import qualified Data.Text as T
2019-09-17 19:29:56 +00:00
-- imports from "mateamt"
import qualified "mateamt" Types as MT
2019-09-08 00:37:50 +00:00
-- internal imports
import Types
type UserAPI =
2019-10-04 07:04:23 +00:00
Header "Cookie" T.Text :> (Get '[HTML] UserSelectPage
:<|> "user" :> Capture "id" Int
:> Get '[HTML] UserOverviewPage
2019-09-17 19:29:56 +00:00
:<|> "user" :> "create" :> Get '[HTML] UserNewPage
2019-10-04 07:04:23 +00:00
:<|> "user" :> "create" :> ReqBody '[FormUrlEncoded] MT.UserSubmit
:> Post '[HTML] UserSelectPage
2019-10-13 20:25:05 +00:00
:<|> "product" :> "list" :> QueryParam "refine" MT.ProductRefine
:> Get '[HTML] ProductListPage
2019-10-04 07:04:23 +00:00
:<|> "auth"
:> Get '[HTML]
(Headers
'[ Header "Set-Cookie" T.Text
, Header "Set-Cookie" T.Text
, Header "Set-Cookie" T.Text
]
AuthPage)
:<|> "auth" :> ReqBody '[FormUrlEncoded] AuthReturn
:> Post '[HTML] UserSelectPage
)
2019-09-16 07:44:46 +00:00
( userSelectLink :<|>
userOverviewLink :<|>
2019-09-17 19:29:56 +00:00
userNewLink :<|>
userNewPostLink :<|>
2019-10-13 20:25:05 +00:00
productListLink :<|>
2019-10-04 07:04:23 +00:00
authLink :<|>
authPostLink
2019-09-16 07:44:46 +00:00
) = allLinks (Proxy :: Proxy UserAPI)