♻️ Convierte initialize() y Application en async

`async_trait` se re-exporta desde `pagetop` y se añade al preludio; ya
no es necesario declararlo como dependencia en las extensiones.
`initialize()` es ahora verdaderamente `async` (con `.await`), y
`Application::new()` y `prepare()` pasan también a ser funciones
`async`.
This commit is contained in:
Manuel Cillero 2026-07-04 22:56:19 +02:00
parent 54d5b3e53d
commit 8aa4372bdf
16 changed files with 159 additions and 107 deletions

View file

@ -2,5 +2,5 @@ use pagetop::prelude::*;
#[pagetop::main]
async fn main() -> std::io::Result<()> {
Application::new().run()?.await
Application::new().await.run().await
}

View file

@ -437,5 +437,5 @@ fn form_lists() -> Form {
#[pagetop::main]
async fn main() -> std::io::Result<()> {
Application::prepare(&FormControls).run()?.await
Application::prepare(&FormControls).await.run().await
}

View file

@ -23,5 +23,5 @@ async fn hello_name(
#[pagetop::main]
async fn main() -> std::io::Result<()> {
Application::prepare(&HelloName).run()?.await
Application::prepare(&HelloName).await.run().await
}

View file

@ -20,5 +20,5 @@ async fn hello_world(request: HttpRequest) -> Result<Markup, ErrorPage> {
#[pagetop::main]
async fn main() -> std::io::Result<()> {
Application::prepare(&HelloWorld).run()?.await
Application::prepare(&HelloWorld).await.run().await
}

View file

@ -78,5 +78,5 @@ async fn intro_colors(request: HttpRequest) -> Result<Markup, ErrorPage> {
#[pagetop::main]
async fn main() -> std::io::Result<()> {
Application::prepare(&IntroColors).run()?.await
Application::prepare(&IntroColors).await.run().await
}

View file

@ -5,6 +5,7 @@ include_locales!(LOC from "examples/locale");
struct SuperMenu;
#[async_trait]
impl Extension for SuperMenu {
fn dependencies(&self) -> Vec<ExtensionRef> {
vec![
@ -14,7 +15,7 @@ impl Extension for SuperMenu {
]
}
fn initialize(&self) {
async fn initialize(&self) {
let navbar_menu = bs::Navbar::brand_left(bs::navbar::Brand::new())
.with_expand(token::BreakPoint::LG)
.with_item(bs::navbar::Item::nav(
@ -114,5 +115,5 @@ impl Extension for SuperMenu {
#[pagetop::main]
async fn main() -> std::io::Result<()> {
Application::prepare(&SuperMenu).run()?.await
Application::prepare(&SuperMenu).await.run().await
}