How to change request in route acting as a simple reverse proxy returning the response? #2832
-
I need to add to my
In Go I'm using this simple code: reverseProxy := &httputil.ReverseProxy{Director: func(r *http.Request) {
r.URL.Scheme = "http"
r.URL.Host = "host_2:1234"
}}
router.Group("/some_route", func(group *Group) {
group.GET("*", reverseProxy)
}) In Rust I don't understand how to do: #[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.service(hello)
.route("/some_route", web::get().wrap(SOME_MIDDLEWARE_HERE?).to(WHAT_HERE?)) // This is the line
})
.bind(("127.0.0.1", 8000))?
.run()
.await
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It's more complicated in Rust of course because there's no built in reverse proxy tools. We have a somewhat naiive example here though: https://github.com/actix/examples/blob/master/http-proxy/src/main.rs |
Beta Was this translation helpful? Give feedback.
It's more complicated in Rust of course because there's no built in reverse proxy tools.
We have a somewhat naiive example here though: https://github.com/actix/examples/blob/master/http-proxy/src/main.rs