2019-06-12 18:14:10 -04:00
|
|
|
// <request-routing>
|
2019-06-16 23:37:14 -04:00
|
|
|
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
|
2019-06-12 18:14:10 -04:00
|
|
|
|
2019-06-16 23:37:14 -04:00
|
|
|
fn index(_req: HttpRequest) -> impl Responder {
|
|
|
|
"Hello from the index page."
|
2019-06-12 18:14:10 -04:00
|
|
|
}
|
|
|
|
|
2019-06-16 23:37:14 -04:00
|
|
|
fn hello(path: web::Path<String>) -> impl Responder {
|
|
|
|
format!("Hello {}!", &path)
|
2019-06-12 18:14:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
HttpServer::new(|| {
|
|
|
|
App::new()
|
|
|
|
.service(web::resource("/").to(index))
|
|
|
|
.service(web::resource("/{name}").to(hello))
|
|
|
|
})
|
2019-06-13 00:32:48 -04:00
|
|
|
.bind("127.0.0.1:8088")
|
2019-06-12 18:14:10 -04:00
|
|
|
.unwrap()
|
|
|
|
.run()
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
// </request-routing>
|