1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 10:27:42 +02:00

standardize future types to ones from actix_utils

This commit is contained in:
Rob Ede
2021-12-08 07:29:12 +00:00
parent ec66754c0d
commit 56051786a6
19 changed files with 51 additions and 40 deletions

View File

@ -17,8 +17,9 @@ name = "actix_cors"
path = "src/lib.rs"
[dependencies]
actix-web = { version = "4.0.0-beta.10", default-features = false }
actix-service = "2.0.0"
actix-utils = "3"
actix-web = { version = "4.0.0-beta.10", default-features = false }
derive_more = "0.99.5"
futures-util = { version = "0.3.7", default-features = false }
@ -28,5 +29,5 @@ smallvec = "1.6"
[dev-dependencies]
actix-rt = "2"
pretty_env_logger = "0.4"
env_logger = "0.9"
regex = "1.4"

View File

@ -3,7 +3,7 @@ use actix_web::{http::header, web, App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
pretty_env_logger::init();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
HttpServer::new(move || {
App::new()

View File

@ -2,6 +2,7 @@ use std::{
collections::HashSet, convert::TryInto, error::Error as StdError, iter::FromIterator, rc::Rc,
};
use actix_utils::future::{self, Ready};
use actix_web::{
body::MessageBody,
dev::{RequestHead, Service, ServiceRequest, ServiceResponse, Transform},
@ -9,7 +10,6 @@ use actix_web::{
http::{self, header::HeaderName, Error as HttpError, HeaderValue, Method, Uri},
Either,
};
use futures_util::future::{self, Ready};
use log::error;
use once_cell::sync::Lazy;
use smallvec::smallvec;

View File

@ -1,5 +1,6 @@
use std::{collections::HashSet, convert::TryInto, error::Error as StdError, rc::Rc};
use actix_utils::future::{ok, Either, Ready};
use actix_web::{
body::{AnyBody, MessageBody},
dev::{Service, ServiceRequest, ServiceResponse},
@ -10,7 +11,7 @@ use actix_web::{
},
HttpResponse,
};
use futures_util::future::{ok, Either, FutureExt as _, LocalBoxFuture, Ready, TryFutureExt as _};
use futures_util::future::{FutureExt as _, LocalBoxFuture, TryFutureExt as _};
use log::debug;
use crate::{builder::intersperse_header_values, AllOrSome, Inner};
@ -155,7 +156,7 @@ where
if self.inner.preflight && req.method() == Method::OPTIONS {
let inner = Rc::clone(&self.inner);
let res = Self::handle_preflight(&inner, req);
Either::Left(ok(res))
Either::left(ok(res))
} else {
let origin = req.headers().get(header::ORIGIN).cloned();
@ -163,7 +164,7 @@ where
// Only check requests with a origin header.
if let Err(err) = self.inner.validate_origin(req.head()) {
debug!("origin validation failed; inner service is not called");
return Either::Left(ok(req.error_response(err)));
return Either::left(ok(req.error_response(err)));
}
}
@ -183,7 +184,7 @@ where
.map_ok(|res| res.map_body(|_, body| AnyBody::new_boxed(body)))
.boxed_local();
Either::Right(res)
Either::right(res)
}
}
}

View File

@ -1,11 +1,11 @@
use actix_service::fn_service;
use actix_utils::future::ok;
use actix_web::{
dev::{ServiceRequest, Transform},
http::{header, HeaderValue, Method, StatusCode},
test::{self, TestRequest},
HttpResponse,
};
use futures_util::future::ok;
use regex::bytes::Regex;
use actix_cors::Cors;