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

25 lines
749 B
Rust

use actix_web::{guard, web, App, HttpResponse, HttpServer};
// <vh>
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(
web::scope("/")
.guard(guard::Header("Host", "www.rust-lang.org"))
.route("", web::to(|| async { HttpResponse::Ok().body("www") })),
)
.service(
web::scope("/")
.guard(guard::Header("Host", "users.rust-lang.org"))
.route("", web::to(|| async { HttpResponse::Ok().body("user") })),
)
.route("/", web::to(HttpResponse::Ok))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
// </vh>