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

Custom headers don't apply to directory indexes #42

Open
KoltesDigital opened this issue Apr 13, 2021 · 3 comments
Open

Custom headers don't apply to directory indexes #42

KoltesDigital opened this issue Apr 13, 2021 · 3 comments

Comments

@KoltesDigital
Copy link

Hi, thanks for your image.

I've tried to use the custom headers feature. They work for files, but not for directories, although requesting a directory leads to its index.html. To be more precise, a config entry with "path": "*", "fileExtension": "html" does apply when requesting /path/index.html, but does not for /path, although the response body is the same.

The code at

reqFileExtension := filepath.Ext(r.URL.Path)
shows that the middleware applies to the URL. Would it be possible to apply to the resolved file instead?

As a side note, I believe path + fileExtension should be superseded by a path glob or a regex, which is more powerful, and is actually not more complex. For instance, a rule with glob /**/ or regex \/$ would apply to any directory, and a rule with glob /**/*.css (or maybe even *.css) or regex \.css$ would apply to any CSS file.

@PierreZ
Copy link
Owner

PierreZ commented Apr 15, 2021

Hi @KoltesDigital!

You are welcome to open a PR if you want to contribute to goStatic.

@KoltesDigital
Copy link
Author

I'm willing to! I saw not-replied issues and wasn't sure you were still maintaining the project.

In order not to work for nothing, will you consider a PR that takes indexes into account, and I think it's better to open another one to add glob/regex to rules? I would not remove the current path + fileExtension to stay backward compatible.

@PierreZ
Copy link
Owner

PierreZ commented Apr 21, 2021

I'm willing to! I saw not-replied issues and wasn't sure you were still maintaining the project.

Oups, I missed some notifications it seems.

In order not to work for nothing, will you consider a PR that takes indexes into account, and I think it's better to open another one to add glob/regex to rules? I would not remove the current path + fileExtension to stay backward compatible.

👍👍 Looking forward for those two PRs 😄

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

No branches or pull requests

2 participants