ebook-manager/src/API.hs

39 lines
872 B
Haskell
Raw Normal View History

2018-08-02 22:11:11 +03:00
{-# Language DataKinds #-}
{-# Language TypeFamilies #-}
{-# Language TypeOperators #-}
{-# Language NoImplicitPrelude #-}
{-# Language MultiParamTypeClasses #-}
{-# Language OverloadedStrings #-}
{-# Language TemplateHaskell #-}
{-# Language QuasiQuotes #-}
{-# Language RecordWildCards #-}
{-# Language DeriveGeneric #-}
{-# Language FlexibleInstances #-}
module API (API, handler) where
import Servant
import Servant.HTML.Lucid (HTML)
2018-08-02 22:32:23 +03:00
import Types
2018-08-02 23:59:08 +03:00
2018-08-05 00:14:30 +03:00
import View
2018-08-03 23:36:38 +03:00
import qualified API.Users as Users
2018-08-02 22:11:11 +03:00
data Index = Index
2018-08-05 00:14:30 +03:00
type API = Get '[HTML] (AppView Index)
2018-08-03 23:36:38 +03:00
:<|> Users.API
2018-08-02 22:11:11 +03:00
2018-08-02 22:32:23 +03:00
handler :: ServerT API AppM
2018-08-03 23:36:38 +03:00
handler = indexHandler :<|> Users.handler
2018-08-05 00:14:30 +03:00
instance ToHtml Index where
toHtml _ = do
h1_ [class_ "title"] "Home page"
p_ [class_ "subtitle"] "Hello world"
toHtmlRaw = toHtml
indexHandler :: AppM (AppView Index)
indexHandler = mkView "Home" Index