Add request logger
This commit is contained in:
parent
9857fca38e
commit
0529012574
@ -15,20 +15,24 @@ import Data.Text.Lazy.Encoding (decodeUtf8)
|
||||
import Data.Text.Lazy (toStrict)
|
||||
|
||||
import Web.Spock.Safe
|
||||
import Network.Wai (Middleware)
|
||||
import Network.Wai.Middleware.Static
|
||||
|
||||
import Network.Wai.Middleware.RequestLogger
|
||||
|
||||
logStr :: String -> ActionT IO ()
|
||||
logStr = liftIO . putStrLn
|
||||
|
||||
|
||||
serveStatic :: FilePath -> SpockT IO ()
|
||||
serveStatic = middleware . staticPolicy . addBase
|
||||
serveStatic :: FilePath -> Middleware
|
||||
serveStatic = staticPolicy . addBase
|
||||
|
||||
|
||||
app :: Url -> UrlTable -> SpockT IO ()
|
||||
app url' table = do
|
||||
liftIO (getDataFileName "static/") >>= serveStatic
|
||||
static <- liftIO (getDataFileName "static/")
|
||||
|
||||
middleware (serveStatic static)
|
||||
middleware logStdout
|
||||
|
||||
get "/" $ html (render index)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user