DioxusLabs / DioxusLabs/dioxus
Having A Catch-All Route Produce A 404 Status Code
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
As an example router:
```
#[derive(Debug, Clone, Routable, PartialEq)]
#[rustfmt::skip]
enum Route {
#[layout(Frame)]
#[route("/")]
Home {},
#[route("/about")]
About {},
#[route("/:..route")]
PageNotFound { route: Vec },
}
```
And using the [errors](https://dioxuslabs.com/learn/0.7/essentials/fullstack/errors) example:
```
fn app() -> Element {
rsx! {
ErrorBoundary {
handle_error: move |err| {
// To ensure the HTTP status is still set properly, we need to call `commit_error_status`
let http_error = FullstackContext::commit_error_status(err.error().unwrap());
// and then we can render some pretty fallback UI
rsx! { "An error occurred! {http_error:?}" }
},
Post {}
}
}
}
fn Post() -> Element {
let post_data = use_loader(move || get_post())?;
rsx! { p { "{post_data" } }
}
```
The `ErrorBoundary` is never hit, because the status code sent is always 200 OK.
Is there a straightforward way to have a catch-all route send an error so that the `ErrorBoundary` is activated?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.