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

Using with warp::Filter::recover #37

Closed KobusEllis closed 3 years ago

KobusEllis commented 3 years ago

Would it be possible to make the errors:Error enum public so that it can be used in a warp::Filter::recover implementation?

Currently it is not possible to do something like:

use std::convert::Infallible;
use warp::{Rejection, Reply};
use warp_reverse_proxy::errors::Error;

pub(crate) async fn recover(rejection: Rejection) -> Result<impl Reply, Infallible> {
    if rejection.is_not_found() {
        //
    } else if let Some(err) = err.find::<Error> {
        // Handle reverse proxy errors
    }
    else {
        //
    }

    Ok(())
}
danielSanchezQ commented 3 years ago

Definitely. Let me get back with some feedback about this 😃