Define la estructura para tests y ejemplos

This commit is contained in:
Manuel Cillero 2023-06-09 10:33:54 +02:00
parent cd76355430
commit 0af85c4d77
14 changed files with 74 additions and 24 deletions

4
examples/Cargo.toml Normal file
View file

@ -0,0 +1,4 @@
[workspace]
members = [
"hello-world",
]

View file

@ -0,0 +1,9 @@
[package]
name = "example_hello_world"
version = "0.0.0"
edition = "2021"
publish = false
[dependencies]
actix-web = "4"
pagetop = { version = "0.0", path = "../../pagetop" }

View file

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