ebook-manager/backend/src/API.hs

49 lines
1.2 KiB
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-05 23:13:49 +03:00
import qualified API.Channels as Channels
2018-08-05 23:42:37 +03:00
import qualified API.Books as Books
import qualified API.Catalogue as Catalogue
2018-08-03 23:36:38 +03:00
2018-08-02 22:11:11 +03:00
data Index = Index
2018-11-12 21:32:42 +02:00
type API = Users.API
:<|> "api" :> "current" :> Channels.API
:<|> "api" :> "current" :> Books.API
:<|> "api" :> "1" :> Catalogue.VersionedAPI 1
:<|> "api" :> "current" :> Catalogue.VersionedAPI 1
2018-08-02 22:11:11 +03:00
2018-08-02 22:32:23 +03:00
handler :: ServerT API AppM
2018-11-12 21:32:42 +02:00
handler = Users.handler
2018-08-05 23:13:49 +03:00
:<|> Channels.handler
2018-08-05 23:42:37 +03:00
:<|> Books.handler
:<|> Catalogue.handler
:<|> Catalogue.handler
2018-08-03 23:36:38 +03:00
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