pagetop/examples/hello-name.rs
Manuel Cillero c1afe0e70c ♻️ Migra API pública de actix-web a Axum
- `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.
2026-05-31 23:38:43 +02:00

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
}