leptos-rs / start-axum

Starter template for use with the Leptos web framework and Axum.
The Unlicense
141 stars 26 forks source link

Serve compressed assets by default #38

Closed CorvusPrudens closed 5 months ago

CorvusPrudens commented 6 months ago

This PR adjusts the file-serving code to serve compressed assets, if present. If static assets are not compressed, the behavior should remain unchanged.

Since the --precompress option in cargo-leptos is such a great and convenient feature, I thought it would be nice to make it easy to get working with this starter template!

One potential downside of this addition is that subsequent recompiles without --precompress may not be served correctly, as the file server will prefer the compressed files. I deemed this acceptable since files are not compressed by default.

Sorry for the messy diff! It looks like the file wasn't previously run through rustfmt. I should also note that I made an opinionated change to the error message, but I thought it would make an actual panic a little more clear.

gbj commented 5 months ago

Sorry for the delayed response -- Looks good, and thanks!

CorvusPrudens commented 5 months ago

Oh no! My bad -- I forgot to mention there's actually a problem with this implementation. There seems to be some interaction between the headers that are let through to the directory server causing 404s. I have a patch open at #41.