📝 Incluye el primer ejemplo en la documentación
This commit is contained in:
parent
2f4184fe26
commit
4054715591
7 changed files with 54 additions and 18 deletions
26
examples/basics/hello-world/src/main.rs
Normal file
26
examples/basics/hello-world/src/main.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue