1
0
mirror of https://github.com/actix/actix-website synced 2024-11-30 11:12:57 +01:00
actix-website/examples/url-dispatch/src/resource.rs
2022-02-26 03:56:24 +00:00

20 lines
534 B
Rust

// <resource>
use actix_web::{guard, web, App, HttpResponse};
async fn index() -> HttpResponse {
HttpResponse::Ok().body("Hello")
}
pub fn main() {
App::new()
.service(web::resource("/prefix").to(index))
.service(
web::resource("/user/{name}")
.name("user_detail")
.guard(guard::Header("content-type", "application/json"))
.route(web::get().to(HttpResponse::Ok))
.route(web::put().to(HttpResponse::Ok)),
);
}
// </resource>