DioxusLabs / DioxusLabs/dioxus
Please change the function signature of `dioxus::server::router` to allow users to set the state type
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
I want to be able to set the state type on the router that's created when using the `dioxus::server::router` function.
## Implement Suggestion
The function is located in https://github.com/DioxusLabs/dioxus/blob/main/packages/fullstack-server/src/launch.rs
line 96.
change it from:
```rust
pub fn router(app: fn() -> Element) -> Router {
//....
}
```
to:
```rust
pub fn router(app: fn() -> Element) -> Router { // Setting the default to `()` should ensure compatability with existing apps
//....
}
```
That way I can do this:
```rust
dioxus::server::router::(App).with_state(store) // a struct wrapped in an Arc
```
You'll probably have to update some of the other functions that expect just a `Router` like `serve`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.