- `configure_service` como `configure_router(Router) -> Router`. - Macro `static_files_service!` como `serve_static_files!`. - `ResultPage<M, E>` eliminado; handlers devuelven `Result<M, E>`. - `ErrorPage` implementa `IntoResponse` en lugar de `ResponseError`. - Registro con `OnceLock`; eliminados `drop_extensions` y `app.welcome`. - `Redirect` devuelve `Response`; docs y ejemplos actualizados.
24 lines
573 B
Rust
24 lines
573 B
Rust
use pagetop::prelude::*;
|
|
|
|
struct HelloWorld;
|
|
|
|
impl Extension for HelloWorld {
|
|
fn configure_router(&self, router: Router) -> Router {
|
|
router.route("/", web::get(hello_world))
|
|
}
|
|
}
|
|
|
|
async fn hello_world(request: HttpRequest) -> Result<Markup, ErrorPage> {
|
|
Page::new(request)
|
|
.with_child(Html::with(|_| {
|
|
html! {
|
|
h1 style="text-align: center;" { "Hello World!" }
|
|
}
|
|
}))
|
|
.render()
|
|
}
|
|
|
|
#[pagetop::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
Application::prepare(&HelloWorld).run()?.await
|
|
}
|