summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/src/Minilang/App.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lambda-calcul/haskell/src/Minilang/App.hs')
-rw-r--r--lambda-calcul/haskell/src/Minilang/App.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/lambda-calcul/haskell/src/Minilang/App.hs b/lambda-calcul/haskell/src/Minilang/App.hs
index 2d21961..8c1fb2b 100644
--- a/lambda-calcul/haskell/src/Minilang/App.hs
+++ b/lambda-calcul/haskell/src/Minilang/App.hs
@@ -1,14 +1,20 @@
module Minilang.App where
-import Minilang.API (LambdaAPI, Score (..))
-import Servant.Server (Handler, Server)
-import Data.Time (getCurrentTime)
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
+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")