♻️ Major code restructuring
This commit is contained in:
parent
a96e203bb3
commit
fa66d628a0
221 changed files with 228 additions and 315 deletions
26
examples/hello-name.rs
Normal file
26
examples/hello-name.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use pagetop::prelude::*;
|
||||
|
||||
#[derive(AssignHandle)]
|
||||
struct HelloName;
|
||||
|
||||
impl PackageTrait for HelloName {
|
||||
fn configure_service(&self, scfg: &mut service::web::ServiceConfig) {
|
||||
scfg.service(hello_name);
|
||||
}
|
||||
}
|
||||
|
||||
#[service::get("/hello/{name}")]
|
||||
async fn hello_name(
|
||||
request: service::HttpRequest,
|
||||
path: service::web::Path<String>,
|
||||
) -> ResultPage<Markup, ErrorPage> {
|
||||
let name = path.into_inner();
|
||||
Page::new(request)
|
||||
.with_component_in("content", Html::with(html! { h1 { "Hello " (name) "!" } }))
|
||||
.render()
|
||||
}
|
||||
|
||||
#[pagetop::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
Application::prepare(&HelloName).unwrap().run()?.await
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue