mirror of
https://github.com/actix/actix-website
synced 2024-11-30 19:14:36 +01:00
20 lines
534 B
Rust
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>
|