actix / actix-web

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.
https://actix.rs
Apache License 2.0
21.6k stars 1.67k forks source link

Cannot use custom built middleware #1187

Closed dsietz closed 4 years ago

dsietz commented 4 years ago

I built my own actix-web middleware (DUAEnforcer) but cannot use it in a App::new().wrap(DUAEnforcer) call. My code is located at https://github.com/dsietz/pbd/blob/master/src/dua/middleware/actix.rs and the test test_add_middleware() fails with the following error:

error[E0277]: the trait bound `dua::middleware::actix::DUAEnforcer: dua::extractor::actix_service::IntoTransform<_, dua::extractor::actix_web::app_service::AppRouting>` is not satisfied
   --> src\dua\middleware\actix.rs:115:19
    |
115 |             .wrap(DUAEnforcer)
    |                   ^^^^^^^^^^^ the trait `dua::extractor::actix_service::IntoTransform<_, dua::extractor::actix_web::app_service::AppRouting>` is not implemented for `dua::middleware::actix::DUAEnforcer`

I'm currently using older versions, but even tried the alpha versions (which caused other complie issues)

actix-web = { version = "1.0.9", optional = true }
actix-service = { version = "0.4.2", optional = true }

Do you have an idea what I'm doing wrong?

dsietz commented 4 years ago

I think I figured out the issue. I removed the use of the LocalError and reverted back to the actix_web::Error and it seems to works.

dsietz commented 4 years ago

I was able to resolve the issue. It was an error in my code as stated above.