1
0
mirror of https://github.com/actix/actix-website synced 2024-12-02 19:52:23 +01:00
actix-website/examples/url-dispatch/src/resource.rs

20 lines
534 B
Rust
Raw Normal View History

2018-05-24 19:13:55 +02:00
// <resource>
2019-06-26 00:20:36 +02:00
use actix_web::{guard, web, App, HttpResponse};
2018-05-24 19:13:55 +02:00
2022-02-26 04:56:24 +01:00
async fn index() -> HttpResponse {
2019-06-26 00:20:36 +02:00
HttpResponse::Ok().body("Hello")
2018-05-24 19:13:55 +02:00
}
pub fn main() {
2018-05-24 19:13:55 +02:00
App::new()
2019-06-17 10:12:11 +02:00
.service(web::resource("/prefix").to(index))
2019-06-17 08:08:42 +02:00
.service(
2019-06-26 00:20:36 +02:00
web::resource("/user/{name}")
.name("user_detail")
.guard(guard::Header("content-type", "application/json"))
2022-02-26 04:56:24 +01:00
.route(web::get().to(HttpResponse::Ok))
.route(web::put().to(HttpResponse::Ok)),
2019-06-17 08:08:42 +02:00
);
2018-05-24 19:13:55 +02:00
}
// </resource>