weavejester / compojure

A concise routing library for Ring/Clojure
Eclipse Public License 1.0
4.08k stars 259 forks source link

Allow static files to be conditionally excluded #180

Closed EvanHahn closed 4 years ago

EvanHahn commented 6 years ago

This adds an :exclude? option to route/files and route/resources. This option is a function that will be called with the current request, and if the function returns true, the file will be ignored.

This is an updated version of #174.

weavejester commented 6 years ago

Thanks for the PR, and sorry I've been so late to respond to this. I'm not sure the best way of doing this, whether to use a predicate on the whole request, or a regular expression on the resource or file path, or just to have a :dot-files? option that is more specific, but would account for most cases.

EvanHahn commented 6 years ago

I'd vote to add this option as is and document several common use cases. I think that lets it be easy for developers (just copy it from the docs) and still be flexible.

EvanHahn commented 4 years ago

Bumping this. Is this something we want to merge? (No rush!)

weavejester commented 4 years ago

Thanks for reminding me about this. Having come back to this I'm now a little more certain what I want.

:exclude? should be :exclude, and it should be a function on the file or resource name.

Make sure all lines are wrapped at 80 characters, and preserve existing indentation.

EvanHahn commented 4 years ago

Unfortunately, I don't think I have time to finish this pull request. I'm going to close this for now, but anyone can feel free to commandeer this branch and see it through.