Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a passthrough for scoped middleware in actix-web #1196

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions utoipa-actix-web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog - utoipa-actix-web

## 0.1.2 - Nov 8 2024

### Added

* Add passthrough for `Scope::wrap` (https://github.com/juhaku/utoipa/pull/1196)

## 0.1.1 - Oct 30 2024

### Changed
Expand Down
2 changes: 1 addition & 1 deletion utoipa-actix-web/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "utoipa-actix-web"
description = "Utoipa's actix-web bindings for seamless integration of the two"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
29 changes: 28 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,33 @@ 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
Loading