danielSanchezQ / warp-reverse-proxy

Fully composable warp filter that can be used as a reverse proxy.
https://github.com/danielSanchezQ/warp-reverse-proxy
MIT License
48 stars 18 forks source link

Pass specified client to execute requests #55

Closed shanmiteko closed 2 years ago

shanmiteko commented 2 years ago

e.g. according to the different host choose different client

warp::any()
    .and(warp::host::optional())
    .and_then(extract_host_from_authority)
    .map(|host: String| (format!("https://{}", host), String::new()))
    .untuple_one()
    .and(extract_request_data_filter())
    .and(with_client(
        CLIENT_DISABLE_SNI
        .get()
        .expect("cannot get client that disable sni"),
    ))
    .and_then(proxy_to_and_forward_response_use_client)
danielSanchezQ commented 2 years ago

Hi @shanmiteko , thanks for the PR! 😄 I like the approach, but I would rather see it as an add-on rather than a full API change. Also I am not sure if using a filter to add the client is the best idea neither. Probably we can use with instead. If you wish to continue developing this I would be happy about it, otherwise we can open an issue for it.

shanmiteko commented 2 years ago

Thanks for your immediate reply!

I don't know if there is a better solution, so I will only use it in my case. (^o^)