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
|
2018-08-14 00:03:52 +03:00
|
|
|
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-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-14 00:03:52 +03:00
|
|
|
:<|> "api" :> Channels.API
|
|
|
|
:<|> "api" :> 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-08-05 23:13:49 +03:00
|
|
|
handler = indexHandler
|
|
|
|
:<|> Users.handler
|
|
|
|
:<|> Channels.handler
|
2018-08-05 23:42:37 +03:00
|
|
|
:<|> Books.handler
|
2018-08-14 00:03:52 +03:00
|
|
|
:<|> 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
|