mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 18:37:41 +02:00
fix doctest ci (#188)
This commit is contained in:
@ -81,7 +81,7 @@ impl AuthExtractorConfig for Config {
|
||||
///
|
||||
/// fn main() {
|
||||
/// let app = App::new()
|
||||
/// .data(Config::default().realm("Restricted area"))
|
||||
/// .app_data(Config::default().realm("Restricted area"))
|
||||
/// .service(web::resource("/index.html").route(web::get().to(index)));
|
||||
/// }
|
||||
/// ```
|
||||
|
@ -84,7 +84,7 @@ impl AuthExtractorConfig for Config {
|
||||
///
|
||||
/// fn main() {
|
||||
/// let app = App::new()
|
||||
/// .data(
|
||||
/// .app_data(
|
||||
/// Config::default()
|
||||
/// .realm("Restricted area")
|
||||
/// .scope("email photo"),
|
||||
|
@ -1,8 +1,12 @@
|
||||
//! HTTP Authentication middleware.
|
||||
|
||||
use std::{future::Future, marker::PhantomData, pin::Pin, rc::Rc, sync::Arc};
|
||||
use std::{
|
||||
error::Error as StdError, future::Future, marker::PhantomData, pin::Pin, rc::Rc,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use actix_web::{
|
||||
body::{AnyBody, MessageBody},
|
||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
||||
Error,
|
||||
};
|
||||
@ -120,8 +124,10 @@ where
|
||||
F: Fn(ServiceRequest, T) -> O + 'static,
|
||||
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
|
||||
T: AuthExtractor + 'static,
|
||||
B: MessageBody + 'static,
|
||||
B::Error: StdError,
|
||||
{
|
||||
type Response = ServiceResponse<B>;
|
||||
type Response = ServiceResponse;
|
||||
type Error = Error;
|
||||
type Transform = AuthenticationMiddleware<S, F, T>;
|
||||
type InitError = ();
|
||||
@ -153,10 +159,12 @@ where
|
||||
F: Fn(ServiceRequest, T) -> O + 'static,
|
||||
O: Future<Output = Result<ServiceRequest, Error>> + 'static,
|
||||
T: AuthExtractor + 'static,
|
||||
B: MessageBody + 'static,
|
||||
B::Error: StdError,
|
||||
{
|
||||
type Response = ServiceResponse<B>;
|
||||
type Response = ServiceResponse;
|
||||
type Error = S::Error;
|
||||
type Future = LocalBoxFuture<'static, Result<ServiceResponse<B>, Error>>;
|
||||
type Future = LocalBoxFuture<'static, Result<ServiceResponse, Error>>;
|
||||
|
||||
actix_service::forward_ready!(service);
|
||||
|
||||
@ -177,7 +185,10 @@ where
|
||||
// middleware to do their thing (eg. cors adding headers)
|
||||
let req = process_fn(req, credentials).await?;
|
||||
|
||||
service.call(req).await
|
||||
service
|
||||
.call(req)
|
||||
.await
|
||||
.map(|res| res.map_body(|_, body| AnyBody::from_message(body)))
|
||||
}
|
||||
.boxed_local()
|
||||
}
|
||||
|
Reference in New Issue
Block a user