Skip to content

Commit

Permalink
Added a passthrough for scoped middleware in Actix-web
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-incubiq committed Nov 8, 2024
1 parent 44ded6b commit e737ccb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion utoipa-actix-web/src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use core::fmt;
use std::cell::{Cell, RefCell};

use actix_service::{IntoServiceFactory, ServiceFactory};
use actix_service::{IntoServiceFactory, ServiceFactory, Transform};
use actix_web::body::MessageBody;
use actix_web::dev::{AppService, HttpServiceFactory, ServiceRequest, ServiceResponse};
use actix_web::guard::Guard;
Expand Down Expand Up @@ -97,6 +97,16 @@ where
Self(self.0.app_data(data), self.1, self.2)
}

/// Passthrough implementation for [`actix_web::Scope::wrap`].
pub fn wrap<M, B>(self, middleware: M) -> Scope<impl ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse<B>, Error = Error, InitError = ()>>
where
M: Transform<T::Service, ServiceRequest, Response = ServiceResponse<B>, Error = Error, InitError = ()> + 'static,
B: MessageBody,
{
let scope = self.0.wrap(middleware);
Scope(scope, self.1, self.2)
}

/// Synonymous for [`UtoipaApp::configure`][utoipa_app_configure]
///
/// [utoipa_app_configure]: ../struct.UtoipaApp.html#method.configure
Expand Down

0 comments on commit e737ccb

Please sign in to comment.