main.rs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // This test is used by playwright configured in the root of the repo
  2. // Tests:
  3. // - 200 Routes
  4. // - 404 Routes
  5. // - 500 Routes
  6. #![allow(non_snake_case)]
  7. use dioxus::{prelude::*, CapturedError};
  8. fn main() {
  9. dioxus::LaunchBuilder::new()
  10. .with_cfg(server_only! {
  11. dioxus::fullstack::ServeConfig::builder().enable_out_of_order_streaming()
  12. })
  13. .launch(app);
  14. }
  15. fn app() -> Element {
  16. rsx! { Router::<Route> {} }
  17. }
  18. #[derive(Clone, Routable, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
  19. enum Route {
  20. #[route("/")]
  21. Home,
  22. #[route("/blog/:id/")]
  23. Blog { id: i32 },
  24. #[route("/error")]
  25. ThrowsError,
  26. }
  27. #[component]
  28. fn Blog(id: i32) -> Element {
  29. rsx! {
  30. Link { to: Route::Home {}, "Go home" }
  31. "id: {id}"
  32. }
  33. }
  34. #[component]
  35. fn ThrowsError() -> Element {
  36. return Err(RenderError::Aborted(CapturedError::from_display(
  37. "This route tests uncaught errors in the server",
  38. )));
  39. }
  40. #[component]
  41. fn Home() -> Element {
  42. rsx! {
  43. "Home"
  44. }
  45. }