DioxusLabs / DioxusLabs/dioxus
Documentation: Indicate that layers should be added before routes
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
I ran into an issue where `extract` run from within server functions failed to extract anything. After lots of head-banging and confusion, I discovered that layers had to be added *after* routes. So, IOW:
```
let router = axum::Router::new()
.serve_dioxus_application(ServeConfigBuilder::new(), App)
.layer(Extension(redis))
.layer(Extension(s3))
.into_make_service();
```
instead of:
```
let router = axum::Router::new()
.layer(Extension(redis))
.layer(Extension(s3))
.serve_dioxus_application(ServeConfigBuilder::new(), App)
.into_make_service();
```
I recognize that this *is* technically documented on the Axum side, but it's a bit indirect as it needs you to recognize that `.serve_dioxus_application` is setting up your routes, and that layers need to be added before. Even so, if there's some way to document it on the Dioxus side, or to make the Dioxus server setup immune to this somehow, that'd have saved me a few hours of debugging.
Thanks a bunch.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.