`configure_router()` recibe Routes, que no monta ninguna ruta sin su Access: `route()`, `public_route()` y `admin_route()`, que toma el permiso de la página del panel de la que cuelga. Una ruta del panel montada de otra forma impide arrancar. `configure_middleware()` recibe Layers y `configure_static_files()` recibe StaticFiles, siempre públicos.
26 lines
615 B
Rust
26 lines
615 B
Rust
use pagetop::prelude::*;
|
|
|
|
struct HelloWorld;
|
|
|
|
#[async_trait]
|
|
impl Extension for HelloWorld {
|
|
fn configure_router(&self, routes: Routes) -> Routes {
|
|
routes.public_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()
|
|
.await
|
|
}
|
|
|
|
#[pagetop::main]
|
|
async fn main() -> std::io::Result<()> {
|
|
Application::prepare(&HelloWorld).await.run().await
|
|
}
|