nlopes / actix-web-prom

Actix-web middleware to expose Prometheus metrics
MIT License
89 stars 56 forks source link

Issue when using middleware within a scope #42

Closed stiiifff closed 3 years ago

stiiifff commented 3 years ago

I am trying to use the middleware within a scope e.g.

        App::new()
            .service(
                web::scope("/internal")
                    .wrap(prometheus.clone())
                    .service(web::resource("/").to(|| HttpResponse::Ok())),
            )
            .service(web::resource("/").to(|| HttpResponse::Ok()))

and I'm getting the following error:

error[E0271]: type mismatch resolving `<PrometheusMetrics as Transform<actix_web::scope::ScopeService>>::Response == ServiceResponse`
  --> src/main.rs:11:22
   |
11 |                     .wrap(prometheus.clone())
   |                      ^^^^ expected struct `StreamLog`, found enum `actix_web::dev::Body`
   |
   = note: expected struct `ServiceResponse<StreamLog<_>>`
              found struct `ServiceResponse<actix_web::dev::Body>`