Open matthiask opened 1 day ago
I think this would be a useful feature for a lot of deployments out there, I definitely agree this should be implemented in the near future. I don't think this will be in time for 1.7, but possibly we can target 1.8.
In terms of implementation, here are some notes I can think of at the moment:
--static-path-mount my_app/static --static-patch-route /static
)build_service!
macro here https://github.com/emmett-framework/granian/blob/a6cfc2f1f9d94ae7f57d6400cfee071eac328aa5/src/workers.rs#L169-L180 thus the best implementation would probably be to add a new macro and switch which macro gets used by the accept loop based on wether a static path is defined (on worker boot)/static/../../../some_file_in_root_path
)
From #97
I think it would be very useful to have some sort of static file serving functionality.
Either something like nginx's
try_files
where granian could first check a folder for a match, and if not, fall back to the RSGI/ASGI/WSGI app, or maybe just support mapping URL paths to folders.A plus would be if granian could optionally serve those files with far-future expiry headers. nginx does the following when using
expires max
:From https://nginx.org/en/docs/http/ngx_http_headers_module.html
This is the only feature which is missing for me to make granian a one-stop solution to serve everything with a single ingress, no sidecars or similar.
(I'd be willing to work on this with some guidance, or fund it if that's helpful.)