✅ Define la estructura para tests y ejemplos
This commit is contained in:
parent
cd76355430
commit
0af85c4d77
14 changed files with 74 additions and 24 deletions
4
examples/Cargo.toml
Normal file
4
examples/Cargo.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"hello-world",
|
||||
]
|
||||
9
examples/hello-world/Cargo.toml
Normal file
9
examples/hello-world/Cargo.toml
Normal 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" }
|
||||
20
examples/hello-world/src/main.rs
Normal file
20
examples/hello-world/src/main.rs
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue