Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Custom Headers To File Server #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

frasermince
Copy link

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.

@owickstrom
Copy link
Collaborator

Thanks for the PR! I have some things to consider:

  1. 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 a defaultFileServerOptions and cause less breakage when adding new things.
  2. 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.
  3. 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?

@owickstrom
Copy link
Collaborator

owickstrom commented Dec 29, 2017

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.

@frasermince
Copy link
Author

Okay that sounds reasonable. And by FilePath -> Stats -> Array do you mean the stats type from Node.FS.Stats?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants