`prepare()` de `Component`, `render()` de `Region` y `Template`, y la implementación de `ComponentRender` pasan a ser funciones async. Se actualizan todos los componentes base, helpers, tests y ejemplos.
29 lines
672 B
Rust
29 lines
672 B
Rust
use pagetop::prelude::*;
|
|
|
|
struct HelloName;
|
|
|
|
#[async_trait]
|
|
impl Extension for HelloName {
|
|
fn configure_router(&self, router: Router) -> Router {
|
|
router.route("/hello/{name}", web::get(hello_name))
|
|
}
|
|
}
|
|
|
|
async fn hello_name(
|
|
web::Path(name): web::Path<String>,
|
|
request: HttpRequest,
|
|
) -> Result<Markup, ErrorPage> {
|
|
Page::new(request)
|
|
.with_child(Html::with(move |_| {
|
|
html! {
|
|
h1 style="text-align: center;" { "Hello " (name) "!" }
|
|
}
|
|
}))
|
|
.render()
|
|
.await
|
|
}
|
|
|
|
#[pagetop::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
Application::prepare(&HelloName).await.run().await
|
|
}
|