Skip to content
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

Adding the option to use an fs.FS for the file server middleware #68

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

Conversation

zekroTJA
Copy link

@zekroTJA zekroTJA commented May 8, 2022

This pull request adds the option FS to the ServerOptions of the file server middleware which allows passing an fs.FS as content root.

For example, this makes it possible to use static web files directly compiled into the binary using embed.FS.

When the FS field is specified, this overrides the set RootPath. Otherwise, when FS is not specified, the given (or default) RootPath is used via os.DirFS.

Additionally, I've added a .gitattribute which specifies the contents of file/testdata to be cloned with LF end of lines. Otherwise, all unit tests fail when cloned on a Windows system because files are converted to CLRF.

Add .gitattributes where EOL is set to LF for testdata in file package so that tests would not fail on Windows systems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant