mirror of
https://github.com/actix/actix-website
synced 2025-02-13 08:32:20 +01:00
25 lines
731 B
Rust
25 lines
731 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(|| HttpResponse::Ok().body("www"))),
|
|
)
|
|
.service(
|
|
web::scope("/")
|
|
.guard(guard::Header("Host", "users.rust-lang.org"))
|
|
.route("", web::to(|| HttpResponse::Ok().body("user"))),
|
|
)
|
|
.route("/", web::to(|| HttpResponse::Ok()))
|
|
})
|
|
.bind("127.0.0.1:8080")?
|
|
.run()
|
|
.await
|
|
}
|
|
// </vh>
|