- `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.
27 lines
637 B
Rust
27 lines
637 B
Rust
use pagetop::prelude::*;
|
|
|
|
struct HelloName;
|
|
|
|
impl Extension for HelloName {
|
|
fn configure_router(&self, router: Router) -> Router {
|
|
router.route("/hello/{name}", web::get(hello_name))
|
|
}
|
|
}
|
|
|
|
async fn hello_name(
|
|
request: HttpRequest,
|
|
web::Path(name): web::Path<String>,
|
|
) -> Result<Markup, ErrorPage> {
|
|
Page::new(request)
|
|
.with_child(Html::with(move |_| {
|
|
html! {
|
|
h1 style="text-align: center;" { "Hello " (name) "!" }
|
|
}
|
|
}))
|
|
.render()
|
|
}
|
|
|
|
#[pagetop::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
Application::prepare(&HelloName).run()?.await
|
|
}
|