2019-06-25 18:20:36 -04:00
|
|
|
use actix_web::{web, App, HttpResponse, HttpServer};
|
2018-05-24 10:13:55 -07:00
|
|
|
|
2019-06-13 03:24:25 -04:00
|
|
|
// <scope>
|
2019-06-25 18:20:36 -04:00
|
|
|
fn show_users() -> HttpResponse {
|
|
|
|
HttpResponse::Ok().body("Show users")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn user_detail(_path: web::Path<(u32,)>) -> HttpResponse {
|
|
|
|
HttpResponse::Ok().body("User detail")
|
2018-05-24 10:13:55 -07:00
|
|
|
}
|
|
|
|
|
2019-06-19 00:20:50 -04:00
|
|
|
pub fn main() {
|
2019-06-25 18:20:36 -04:00
|
|
|
HttpServer::new(|| {
|
|
|
|
App::new().service(
|
|
|
|
web::scope("/users")
|
|
|
|
.route("/show", web::get().to(show_users))
|
|
|
|
.route("/show/{id}", web::get().to(user_detail)),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
.bind("127.0.0.1:8088")
|
|
|
|
.unwrap()
|
|
|
|
.run()
|
|
|
|
.unwrap();
|
2018-05-24 10:13:55 -07:00
|
|
|
}
|
2019-06-13 03:24:25 -04:00
|
|
|
// </scope>
|