📝 Incluye el primer ejemplo en la documentación

This commit is contained in:
Manuel Cillero 2023-06-09 19:14:08 +02:00
parent 2f4184fe26
commit 4054715591
7 changed files with 54 additions and 18 deletions

View file

@ -0,0 +1,26 @@
use pagetop::prelude::*;
define_handle!(APP_HELLO_WORLD);
struct HelloWorld;
impl ModuleTrait for HelloWorld {
fn handle(&self) -> Handle {
APP_HELLO_WORLD
}
fn configure_service(&self, cfg: &mut service::web::ServiceConfig) {
cfg.route("/", service::web::get().to(hello_world));
}
}
async fn hello_world(request: service::HttpRequest) -> ResultPage<Markup, FatalError> {
Page::new(request)
.with_in("content", Html::with(html! { h1 { "Hello World!" } }))
.render()
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
Application::prepare(&HelloWorld).unwrap().run()?.await
}