-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Static files and matching #4215
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
Comments
Yes, StaticFiles is a prime candidate for cloning to work as endpoints. In this model I'd expect MapStaticFiles to take StaticFilesOptions and that there'd be a way to add metadata for any matches, like auth policies. Don't forget about DefualtFiles or DirectoryBrowsing. |
This is what I imagined. We want to check for the presence of the file in realtime (or with a cache) rather than computing them all upfront. We might also define some wildcarding or rules so you can do multiple things. |
re: template/guidance update - I totally agree. There are multiple choices about how this would work and only the application developer can decide what is best. We've had the need for this in the past though. For instance there have been a bunch of issues with the spa fallback route. Sometimes you want to write a middleware that runs when nothing was matched. |
Would the matcher do this? Right now it only supports matching static endpoints. What do you think of supporting dynamic endpoint selection in the matcher? We would want to match to a dynamic endpoint, potentially under a static path, e.g. use DFA to match |
I've imagined a feature like this in the past, but I don't understand why it would be needed for static files 🤷♂️ |
Closing this as there is not much customer ask for this. |
I updated a sample to use static files + endpoints + authz. To achieve the desired result I had to write a DIY static file endpoint matcher and it got me thinking.
RANDOM THOUGHT 1
We could add configurable static file matching to
UseEndpointRouting
. It would be useful when you want to run the file through APIs that use endpoints, e.g.AuthorizationMiddleware
. There could be a couple of modes for matching:RANDOM THOUGHT 2
UseStaticFiles
today is terminal if there is a matching file. If static files have endpoints then it could disappear from 3.0 templates and the static file could be returned at the end of the request pipeline.Would there be performance considerations from doing this? It would mean static files experience the entire request pipeline, e.g. if authentication is enabled then static file requests would be authenticated.
Alternatively
UseStaticFiles
could remain present in templates, and if the request was matched to a static file endpoint inUseEndpointRouting
thenUseStaticFiles
would do nothing more than invoke the endpoint and exit.The text was updated successfully, but these errors were encountered: