Skip to content

Commit

Permalink
add logging to the webserver
Browse files Browse the repository at this point in the history
  • Loading branch information
penguinland committed Oct 14, 2024
1 parent 649b55c commit 621770e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ executables:
- Spock
- text
- wai-middleware-static
- wai-extra
5 changes: 4 additions & 1 deletion server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Control.Monad.Trans(liftIO)
import Control.Monad.Trans.State.Strict(runStateT)
import Data.IORef(IORef, newIORef, readIORef, writeIORef)
import Data.Text(pack)
-- Take the `Dev` off the end to get more standardized server logs.
import Network.Wai.Middleware.RequestLogger(logStdoutDev)
import Network.Wai.Middleware.Static(staticPolicy, addBase)
import System.Random(StdGen, getStdGen)
import Web.Spock(SpockM, file, text, get, root, spock, runSpock, json,
Expand All @@ -31,7 +33,8 @@ main = do

app :: SpockM () MySession MyAppState ()
app = do
-- NOTE: these first two are relative to the current working directory when
middleware logStdoutDev
-- NOTE: these next two are relative to the current working directory when
-- you execute the program! So, you need to run it from the right place.
middleware (staticPolicy (addBase "static"))
get root $ file "text/html" "static/index.html"
Expand Down

0 comments on commit 621770e

Please sign in to comment.