pub fn request(config: &Config, req: &Request<Body>) -> Result<Request<Body>, (StatusCode, &'static str)> {
    if req.method() != Method::GET {
        return Err((StatusCode::METHOD_NOT_ALLOWED, "Only GET requests allowed"))
    }

    let mut new_req = Request::builder().uri({
        let req_path = req.uri().path_and_query().expect("request URL should have path").as_str();

        if !req_path.starts_with(&config.strip_prefix) {
            return Err((StatusCode::NOT_FOUND, "Not found"))
        }

        format!("{}{}", config.upstream, &req_path[config.strip_prefix.len()..]).parse::<Uri>().unwrap()
    }).header("X-Via-Zip-Stream", config.via_zip_stream_header_value.clone());

    for header in KEEP_HEADERS {
        if let Some(value) = req.headers().get(header) {
            new_req = new_req.header(header, value);
        }
    }
    
    Ok(new_req.body(Body::empty()).unwrap())
}
/// Modify a client request into an upstream request
Modify a client request into an upstream request
Modify a client request into an upstream request
pub fn request(config: &Config, req: &Request<Body>) -> Result<Request<Body>, (StatusCode, &'static str)> {
    if req.method() != Method::GET {
        return Err((StatusCode::METHOD_NOT_ALLOWED, "Only GET requests allowed"))
    }
    let mut new_req = Request::builder().uri({
        let req_path = req.uri().path_and_query().expect("request URL should have path").as_str();
        if !req_path.starts_with(&config.strip_prefix) {
            return Err((StatusCode::NOT_FOUND, "Not found"))
        }
        format!("{}{}", config.upstream, &req_path[config.strip_prefix.len()..]).parse::<Uri>().unwrap()
    }).header("X-Via-Zip-Stream", config.via_zip_stream_header_value.clone());
    for header in KEEP_HEADERS {
        if let Some(value) = req.headers().get(header) {
            new_req = new_req.header(header, value);
        }
    }
    Ok(new_req.body(Body::empty()).unwrap())
}
pub fn request ( config : & Config , req : & Request < Body > ) -> Result < Request < Body > , ( StatusCode , & ' static str ) > { if req . method ( ) != Method :: GET { return Err ( ( StatusCode :: METHOD_NOT_ALLOWED , " " ) ) } let mut new_req = Request :: builder ( ) . uri ( { let req_path = req . uri ( ) . path_and_query ( ) . expect ( " " ) . as_str ( ) ; if ! req_path . starts_with ( & config . strip_prefix ) { return Err ( ( StatusCode :: NOT_FOUND , " " ) ) } format ! ( " " config upstream req_path [ config strip_prefix len ( ) ] ) . parse :: < Uri > ( ) . unwrap ( ) } ) . header ( " " , config . via_zip_stream_header_value . clone ( ) ) ; for header in KEEP_HEADERS { if let Some ( value ) = req . headers ( ) . get ( header ) { new_req = new_req . header ( header , value ) ; } } Ok ( new_req . body ( Body :: empty ( ) ) . unwrap ( ) ) }
Modify a client request into an upstream request
Modify a client request into an upstream request
config
&Config
req
&Request<Body>
config
&Config
req
&Request<Body>