-
I would like to have a server that has multiple binds like this: HttpServer::new(move || {
...
})
.bind(("0.0.0.0", 80))?
.bind(("127.0.0.1", 8080))? With that, I want certain routes to only be accessible using the second bind |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I think you can have two let server1 = HttpServer::new(move || {
...
})
.bind("0.0.0.0:80")?
.run();
let server2 = HttpServer::new(move || {
...
})
.bind("127.0.0.1:8080")?
.run();
tokio::spawn(server1); // not sure if it will work in #[actix_web::main]
server2.await; |
Beta Was this translation helpful? Give feedback.
-
req.app_config().local_addr() See https://docs.rs/actix-web/latest/actix_web/struct.HttpRequest.html#method.app_config |
Beta Was this translation helpful? Give feedback.
See https://docs.rs/actix-web/latest/actix_web/struct.HttpRequest.html#method.app_config