Open
Description
reset_middleware()
doesn't affect which middleware is ran for a route. With the following code, I'd expect a 200 response with the text "Success!". Instead, the log shows:
thread 'async-std/runtime' panicked at 'Middleware panicked.', src\main.rs:25:9
cargo.toml
[package]
name = "tide-middleware-test"
version = "0.1.0"
edition = "2018"
publish = false
[dependencies]
async-std = { version = "1.6.0", features = ["attributes"] }
tide = "0.16.0"
src/main.rs
use tide::{Middleware, Next, Request, Response, Result};
#[async_std::main]
async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
let mut app = tide::new();
app.with(PanicMiddleware {});
app.at("/").reset_middleware().get(page);
app.listen("0.0.0.0:80").await?;
Ok(())
}
async fn page(_request: Request<()>) -> tide::Result {
Ok("Success!".into())
}
struct PanicMiddleware {}
#[tide::utils::async_trait]
impl<State: Clone + Send + Sync + 'static> Middleware<State> for PanicMiddleware {
async fn handle(&self, _request: Request<State>, _next: Next<'_, State>) -> Result<Response> {
panic!("Middleware panicked.");
}
}