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 Data.Text.Lazy (toStrict)
|
||||||
|
|
||||||
import Web.Spock.Safe
|
import Web.Spock.Safe
|
||||||
|
import Network.Wai (Middleware)
|
||||||
import Network.Wai.Middleware.Static
|
import Network.Wai.Middleware.Static
|
||||||
|
import Network.Wai.Middleware.RequestLogger
|
||||||
|
|
||||||
logStr :: String -> ActionT IO ()
|
logStr :: String -> ActionT IO ()
|
||||||
logStr = liftIO . putStrLn
|
logStr = liftIO . putStrLn
|
||||||
|
|
||||||
|
|
||||||
serveStatic :: FilePath -> SpockT IO ()
|
serveStatic :: FilePath -> Middleware
|
||||||
serveStatic = middleware . staticPolicy . addBase
|
serveStatic = staticPolicy . addBase
|
||||||
|
|
||||||
|
|
||||||
app :: Url -> UrlTable -> SpockT IO ()
|
app :: Url -> UrlTable -> SpockT IO ()
|
||||||
app url' table = do
|
app url' table = do
|
||||||
liftIO (getDataFileName "static/") >>= serveStatic
|
static <- liftIO (getDataFileName "static/")
|
||||||
|
|
||||||
|
middleware (serveStatic static)
|
||||||
|
middleware logStdout
|
||||||
|
|
||||||
get "/" $ html (render index)
|
get "/" $ html (render index)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user