1
0
mirror of https://github.com/actix/actix-website synced 2025-02-09 06:45:37 +01:00

25 lines
731 B
Rust
Raw Normal View History

use actix_web::{guard, web, App, HttpResponse, HttpServer};
2018-06-07 21:08:11 -07:00
// <vh>
2020-09-12 16:21:54 +01:00
#[actix_web::main]
2019-12-29 01:15:22 +09:00
async fn main() -> std::io::Result<()> {
2019-06-13 03:24:25 -04:00
HttpServer::new(|| {
App::new()
.service(
web::scope("/")
.guard(guard::Header("Host", "www.rust-lang.org"))
.route("", web::to(|| HttpResponse::Ok().body("www"))),
2019-06-13 03:24:25 -04:00
)
.service(
web::scope("/")
.guard(guard::Header("Host", "users.rust-lang.org"))
.route("", web::to(|| HttpResponse::Ok().body("user"))),
2019-06-13 03:24:25 -04:00
)
.route("/", web::to(|| HttpResponse::Ok()))
})
2020-09-12 16:21:54 +01:00
.bind("127.0.0.1:8080")?
.run()
2019-12-29 01:15:22 +09:00
.await
2018-06-07 21:08:11 -07:00
}
// </vh>