I am running a Spock server and wanting to serve some static content.
I am using respondMiddleware
function from the "Web.Spock.Action" package.
The signature is:
respondMiddleware :: Monad m => Middleware -> ActionCtxT ctx m a
I am getting this "Middleware" using the staticPolicy
function from "Network.Wai.Middleware.Static" package
staticPolicy :: Policy -> Middleware
And the "Policy" using addBase
from "Network.Wai.Middleware.Static" package
addBase :: String -> Policy
Here is my codeblock:
get ("/") $
respondMiddleware $ staticPolicy $ addBase ("static")
The static
has an index.html
and the related JS and CSS files and it is placed in the root directory of the stack project. The error I get is Failed to load resource: the server responded with a status of 400 (Bad Request)
"/"
in your RouteSpec doesn't have a wildcard, so I think that will only match exactly/
. I suspect what you want ismiddleware $ staticPolicy $ addBase "static"
. – Ephebe