-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite index.html
to /
#16
Comments
I have the same issue. Anyone got a solution to this? I'm using this: cachedStatic :: CacheContainer -> Middleware
cachedStatic cacheContainer =
staticPolicy' cacheContainer
$ rewrite "/" "/index.html"
>-> addBase "public"
where
rewrite from to = policy $ pure . change from to
change from to = (== from) >>= bool id (const to) I've also tried @Profpatsch you have to return the original argument wrapped in a |
Ah, shit, never mind! I just got it to work with @Profpatsch I guess I've answered your question if you still care; you can use something similar to the code above with that minor modification. Here is the relevant policy extracted out (without import statements) for anyone interested: rewrite :: Policy
rewrite from to = policy $ pure . change from to
where
change from to = (== from) >>= bool id (const to) |
@habibalamin That's a handy function to have (both as an example, and for practical use) - might be worth suggesting it be added to the package? btw, I think the signature on that should be |
@phlummox that's a good idea. I wonder if it'd be a good idea to extend it to work for any path ending in Hmm… |
For what it's worth, I think rewrite :: [(String, FilePath)] -> Policy
rewrite mappings = only mappings <|> mempty (read: serve only the given mappings or alternatively anything else) |
Is it possible to rewrite
index.html
so that it is served when the user navigates to/
?I tried something like
But that only lead to my whole server not returning any static file anymore.
The text was updated successfully, but these errors were encountered: