Update actix-web support documentation. (#177)
This commit is contained in:
parent
90cc11e9ce
commit
680607dfae
1 changed files with 9 additions and 15 deletions
|
@ -24,27 +24,21 @@ Actix request handlers can use a `Markup` that implements the `actix_web::Respon
|
||||||
#![feature(proc_macro_hygiene)]
|
#![feature(proc_macro_hygiene)]
|
||||||
|
|
||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
use actix_web::{App, server, Path, http::Method};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
|
||||||
fn index(params: Path<(String, u32)>) -> Markup {
|
fn index(params: web::Path<(String, u32)>) -> Markup {
|
||||||
html! {
|
html! {
|
||||||
h1 { "Hello " (params.0) " with id " (params.1) "!"}
|
h1 { "Hello " (params.0) " with id " (params.1) "!" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() -> std::io::Result<()> {
|
||||||
let sys = actix::System::new("maud-example");
|
HttpServer::new(|| {
|
||||||
|
|
||||||
server::new(move || {
|
|
||||||
App::new()
|
App::new()
|
||||||
.resource("/user/{name}/{id}", |r| {
|
.route("/user/{name}/{id}", web::get().to(index))
|
||||||
r.method(Method::GET).with(index)
|
|
||||||
})
|
})
|
||||||
}).bind("127.0.0.1:8080")
|
.bind("127.0.0.1:8080")?
|
||||||
.unwrap()
|
.run()
|
||||||
.start();
|
|
||||||
|
|
||||||
let _ = sys.run();
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue