1
0
mirror of https://github.com/actix/actix-website synced 2025-02-08 22:36:07 +01:00

25 lines
749 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"))
2022-02-26 03:56:24 +00:00
.route("", web::to(|| async { HttpResponse::Ok().body("www") })),
2019-06-13 03:24:25 -04:00
)
.service(
web::scope("/")
.guard(guard::Header("Host", "users.rust-lang.org"))
2022-02-26 03:56:24 +00:00
.route("", web::to(|| async { HttpResponse::Ok().body("user") })),
2019-06-13 03:24:25 -04:00
)
2022-02-26 03:56:24 +00:00
.route("/", web::to(HttpResponse::Ok))
2019-06-13 03:24:25 -04:00
})
2022-02-26 03:56:24 +00: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>