fix static file serving in local dev, fix edge case in prod#3137
Conversation
|
Write a unit test which starts the server from top level and query a static resource? |
now after having slept, I can see it. starting a test from the top level would either mean re-introducing the top-level crate,
|
|
Yep, changing the cwd was what I had in mind. |
but cwd is always per-process, so with parallel test execution you might break stuff, or we have to set threads=1. But I have another, cleaner idea. I'll inject the root dir into the router builder, and write a test on a "broken" router. |
|
No I mean, when you use |
985c109 to
9dbc7f5
Compare
|
@GuillaumeGomez added some tests, I think this is the better approach. |
|
Does that mean it works wherever we start the server? |
in a dev project, yes. in the built binary, or docker container, no. the fallback is So it might work whereever you try in this repo : |
|
Awesome! Then please update docs as well then I'll approve. :) |
|
@GuillaumeGomez like this? |
|
Yes exactly, thanks! |
fixes a production edge case that would have lead to wrong cache headers when someone locally deletes files from the
staticorvendordirectories that were there at built-time.Also we're fixing a bug when you were locally running the docs.rs webserver from the repository-root. In this case the static assets weren't found, because they don't live in the repo root any more. We fallback to
CARGO_MANIFEST_DIRnow.I added a unit-test for the wrong cache headers in this edge-case, and a first "real" integration test at the repo root that just so happens to test the static asset fetching in development. More integration tests will be added.