diff --git a/Cargo.toml b/Cargo.toml index beaeb0b7..bc279fe5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,16 +11,14 @@ futures-util = "0.3" http = "0.2" http-body = "0.4" hyper = "0.14" -itertools = "0.10" pin-project = "1.0" +regex = "1.5" serde = "1.0" serde_json = "1.0" serde_urlencoded = "0.7" -thiserror = "1.0" +tokio = { version = "1", features = ["time"] } tower = { version = "0.4", features = ["util", "buffer"] } tower-http = { version = "0.1", features = ["add-extension"] } -regex = "1.5" -tokio = { version = "1", features = ["time"] } [dev-dependencies] hyper = { version = "0.14", features = ["full"] } @@ -36,10 +34,10 @@ uuid = "0.8" version = "0.1" features = [ "add-extension", + "auth", "compression", "compression-full", "fs", - "trace", "redirect", - "auth", + "trace", ] diff --git a/src/body.rs b/src/body.rs index 6ba65cbd..cb6f1f38 100644 --- a/src/body.rs +++ b/src/body.rs @@ -3,6 +3,7 @@ use bytes::Bytes; use http_body::{Empty, Full}; use std::{ + error::Error as StdError, fmt, pin::Pin, task::{Context, Poll}, @@ -86,14 +87,17 @@ where /// /// This is necessary for compatibility with middleware that changes the error /// type of the response body. -// work around for `BoxError` not implementing `std::error::Error` -// -// This is currently required since tower-http's Compression middleware's body type's -// error only implements error when the inner error type does: -// https://github.com/tower-rs/tower-http/blob/master/tower-http/src/lib.rs#L310 -// -// Fixing that is a breaking change to tower-http so we should wait a bit, but should -// totally fix it at some point. -#[derive(Debug, thiserror::Error)] -#[error(transparent)] -pub struct BoxStdError(#[from] pub(crate) tower::BoxError); +#[derive(Debug)] +pub struct BoxStdError(pub(crate) tower::BoxError); + +impl StdError for BoxStdError { + fn source(&self) -> std::option::Option<&(dyn StdError + 'static)> { + self.0.source() + } +} + +impl fmt::Display for BoxStdError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.0.fmt(f) + } +} diff --git a/src/routing.rs b/src/routing.rs index 7927b6bb..165ea740 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -6,7 +6,6 @@ use futures_util::{future, ready}; use http::{Method, Request, Response, StatusCode, Uri}; use http_body::Full; use hyper::Body; -use itertools::Itertools; use pin_project::pin_project; use regex::Regex; use std::{ @@ -394,6 +393,7 @@ impl PathPattern { Cow::Borrowed(part) } }) + .collect::>() .join("/"); let full_path_regex =