77 releases (34 breaking)

new 0.73.0 Oct 1, 2024
0.71.1 Aug 18, 2024
0.68.5 Jul 9, 2024
0.66.2 Mar 6, 2024
0.0.1 Oct 10, 2022

#1414 in HTTP server

Download history 613/week @ 2024-06-12 926/week @ 2024-06-19 424/week @ 2024-06-26 501/week @ 2024-07-03 447/week @ 2024-07-10 479/week @ 2024-07-17 665/week @ 2024-07-24 512/week @ 2024-07-31 681/week @ 2024-08-07 864/week @ 2024-08-14 493/week @ 2024-08-21 606/week @ 2024-08-28 638/week @ 2024-09-04 1060/week @ 2024-09-11 1392/week @ 2024-09-18 1109/week @ 2024-09-25

4,289 downloads per month
Used in 3 crates (via salvo)

MIT/Apache

695KB
16K SLoC

salvo-proxy

Proxy for Salvo.

This is offical crate, so you can enable it in Cargo.toml like this:

salvo = { version = "*", features=["proxy"] }

Docs


lib.rs:

Provide proxy support for Savlo web framework.

Example

In this example, if the requested URL begins with http://127.0.0.1:5800/, the proxy goes to https://www.rust-lang.org; if the requested URL begins with http://localhost:5800/, the proxy goes to https://www.rust-lang.org.

use salvo_core::prelude::*;
use salvo_proxy::Proxy;

#[tokio::main]
async fn main() {
    let router = Router::new()
        .push(
            Router::new()
                .host("127.0.0.1")
                .path("<**rest>")
                .goal(Proxy::use_hyper_client("https://www.rust-lang.org")),
        )
        .push(
            Router::new()
                .host("localhost")
                .path("<**rest>")
                .goal(Proxy::use_hyper_client("https://crates.io")),
        );

    let acceptor = TcpListener::new("0.0.0.0:5800").bind().await;
    Server::new(acceptor).serve(router).await;
}

Dependencies

~18–34MB
~631K SLoC