hyper
hyper copied to clipboard
Add Custom Headers To File Server
I needed a way to have custom headers on the FileServer in order to Gzip the contents. I created another parameter to do that. Let me know if this is something that seems like would make sense for this or if there is a better way to do this than another parameter.
Thanks for the PR! I have some things to consider:
- I think it's time to wrap up the arguments in a record, perhaps something like
type FileServerOptions req res c = { on404 :: ..., additionalHeaders :: ... }. Then we can have adefaultFileServerOptionsand cause less breakage when adding new things. - Should the headers thing perhaps be a function instead? E.g.
FilePath -> Stats -> Array (Tuple String String), that can inspect what file is being served and choose headers based on that. - If we decide to go with a function, as discussed in point 2, it could also take the default headers as an argument, and have the possibility to filter them out. Not sure if that is useful, though.
What do you think?
Oh, by the way, have a look at the Travis CI report. There's an example that fails to compile. You can compile them with make examples.
Okay that sounds reasonable. And by FilePath -> Stats -> Array do you mean the stats type from Node.FS.Stats?