summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/src/Minilang/App.hs
blob: 8c1fb2bb8218c6a07745bded4c680298b2583b45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Minilang.App where

import Control.Monad.IO.Class (liftIO)
import Data.Time (getCurrentTime)
import Minilang.API (LambdaAPI, Score (..))
import Network.Wai.Application.Static (defaultFileServerSettings, staticApp)
import Servant ((:<|>) (..))
import Servant.Server (Application, Handler, Server, Tagged (..))

lambdaApp :: Server LambdaAPI
lambdaApp = getLeaderboard :<|> Tagged staticResources

getLeaderboard :: Handler [Score]
getLeaderboard = do
  now <- liftIO getCurrentTime
  pure [Score "Alice" 95 now, Score "Bob" 88 now]

-- | Serve static resources under `public/` directory
staticResources :: Application
staticResources = staticApp (defaultFileServerSettings "public")