1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-02-21 10:04:49 +01:00

Merge pull request #61 from JohnTitor/futures

Minimize `futures` dependency
This commit is contained in:
Yuki Okushi 2020-05-21 17:55:21 +09:00 committed by GitHub
commit 2209359c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 32 additions and 22 deletions

View File

@ -4,6 +4,10 @@
* Minimum supported Rust version(MSRV) is now 1.40.0. * Minimum supported Rust version(MSRV) is now 1.40.0.
## unreleased
* Minimize `futures` dependency
## 0.5.1 (2019-02-17) ## 0.5.1 (2019-02-17)
* Move repository to actix-extras * Move repository to actix-extras

View File

@ -17,7 +17,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
bytes = "0.5" bytes = "0.5"
futures = "0.3.1" futures-util = { version = "0.3.5", default-features = false }
derive_more = "0.99" derive_more = "0.99"
actix-rt = "1" actix-rt = "1"

View File

@ -15,8 +15,8 @@ use actix_web::dev::{HttpResponseBuilder, Payload};
use actix_web::error::{Error, PayloadError, ResponseError}; use actix_web::error::{Error, PayloadError, ResponseError};
use actix_web::http::header::{CONTENT_LENGTH, CONTENT_TYPE}; use actix_web::http::header::{CONTENT_LENGTH, CONTENT_TYPE};
use actix_web::{FromRequest, HttpMessage, HttpRequest, HttpResponse, Responder}; use actix_web::{FromRequest, HttpMessage, HttpRequest, HttpResponse, Responder};
use futures::future::{ready, FutureExt, LocalBoxFuture, Ready}; use futures_util::future::{ready, FutureExt, LocalBoxFuture, Ready};
use futures::StreamExt; use futures_util::StreamExt;
#[derive(Debug, Display)] #[derive(Debug, Display)]
pub enum ProtoBufPayloadError { pub enum ProtoBufPayloadError {

View File

@ -1,5 +1,9 @@
# Changes # Changes
## unreleased
* Minimize `futures` dependency
## [0.9.0-alpha.2] ## [0.9.0-alpha.2]
* Add `cookie_http_only` functionality to RedisSession builder, setting this * Add `cookie_http_only` functionality to RedisSession builder, setting this

View File

@ -30,7 +30,7 @@ actix-utils = "1.0.3"
log = "0.4.6" log = "0.4.6"
backoff = "0.1.5" backoff = "0.1.5"
derive_more = "0.99.2" derive_more = "0.99.2"
futures = "0.3.1" futures-util = { version = "0.3.5", default-features = false }
redis-async = "0.6.1" redis-async = "0.6.1"
actix-rt = "1.0.0" actix-rt = "1.0.0"
time = "0.2.9" time = "0.2.9"

View File

@ -6,7 +6,7 @@ use actix::prelude::*;
use actix_utils::oneshot; use actix_utils::oneshot;
use backoff::backoff::Backoff; use backoff::backoff::Backoff;
use backoff::ExponentialBackoff; use backoff::ExponentialBackoff;
use futures::FutureExt; use futures_util::FutureExt;
use redis_async::error::Error as RespError; use redis_async::error::Error as RespError;
use redis_async::resp::{RespCodec, RespValue}; use redis_async::resp::{RespCodec, RespValue};
use tokio::io::{split, WriteHalf}; use tokio::io::{split, WriteHalf};

View File

@ -10,7 +10,7 @@ use actix_web::cookie::{Cookie, CookieJar, Key, SameSite};
use actix_web::dev::{ServiceRequest, ServiceResponse}; use actix_web::dev::{ServiceRequest, ServiceResponse};
use actix_web::http::header::{self, HeaderValue}; use actix_web::http::header::{self, HeaderValue};
use actix_web::{error, Error, HttpMessage}; use actix_web::{error, Error, HttpMessage};
use futures::future::{ok, Future, Ready}; use futures_util::future::{ok, Future, Ready};
use rand::{distributions::Alphanumeric, rngs::OsRng, Rng}; use rand::{distributions::Alphanumeric, rngs::OsRng, Rng};
use redis_async::resp::RespValue; use redis_async::resp::RespValue;
use time::{self, Duration, OffsetDateTime}; use time::{self, Duration, OffsetDateTime};

View File

@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased] ## [unreleased]
- Update the `base64` dependency to 0.12 - Update the `base64` dependency to 0.12
- AuthenticationError's status code is preserved when converting to a ResponseError - AuthenticationError's status code is preserved when converting to a ResponseError
- Minimize `futures` dependency
## [0.4.1] - 2020-02-19 ## [0.4.1] - 2020-02-19
- Move repository to actix-extras - Move repository to actix-extras

View File

@ -19,7 +19,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "^2.0", default_features = false } actix-web = { version = "^2.0", default_features = false }
actix-service = "1.0" actix-service = "1.0"
futures = "0.3" futures-util = { version = "0.3", default-features = false }
bytes = "0.5" bytes = "0.5"
base64 = "0.12" base64 = "0.12"

View File

@ -5,7 +5,7 @@ use std::borrow::Cow;
use actix_web::dev::{Payload, ServiceRequest}; use actix_web::dev::{Payload, ServiceRequest};
use actix_web::http::header::Header; use actix_web::http::header::Header;
use actix_web::{FromRequest, HttpRequest}; use actix_web::{FromRequest, HttpRequest};
use futures::future; use futures_util::future::{ready, Ready};
use super::config::AuthExtractorConfig; use super::config::AuthExtractorConfig;
use super::errors::AuthenticationError; use super::errors::AuthenticationError;
@ -104,7 +104,7 @@ impl BasicAuth {
} }
impl FromRequest for BasicAuth { impl FromRequest for BasicAuth {
type Future = future::Ready<Result<Self, Self::Error>>; type Future = Ready<Result<Self, Self::Error>>;
type Config = Config; type Config = Config;
type Error = AuthenticationError<Challenge>; type Error = AuthenticationError<Challenge>;
@ -112,7 +112,7 @@ impl FromRequest for BasicAuth {
req: &HttpRequest, req: &HttpRequest,
_: &mut Payload, _: &mut Payload,
) -> <Self as FromRequest>::Future { ) -> <Self as FromRequest>::Future {
future::ready( ready(
Authorization::<Basic>::parse(req) Authorization::<Basic>::parse(req)
.map(|auth| BasicAuth(auth.into_scheme())) .map(|auth| BasicAuth(auth.into_scheme()))
.map_err(|_| { .map_err(|_| {
@ -131,10 +131,10 @@ impl FromRequest for BasicAuth {
impl AuthExtractor for BasicAuth { impl AuthExtractor for BasicAuth {
type Error = AuthenticationError<Challenge>; type Error = AuthenticationError<Challenge>;
type Future = future::Ready<Result<Self, Self::Error>>; type Future = Ready<Result<Self, Self::Error>>;
fn from_service_request(req: &ServiceRequest) -> Self::Future { fn from_service_request(req: &ServiceRequest) -> Self::Future {
future::ready( ready(
Authorization::<Basic>::parse(req) Authorization::<Basic>::parse(req)
.map(|auth| BasicAuth(auth.into_scheme())) .map(|auth| BasicAuth(auth.into_scheme()))
.map_err(|_| { .map_err(|_| {

View File

@ -6,7 +6,7 @@ use std::default::Default;
use actix_web::dev::{Payload, ServiceRequest}; use actix_web::dev::{Payload, ServiceRequest};
use actix_web::http::header::Header; use actix_web::http::header::Header;
use actix_web::{FromRequest, HttpRequest}; use actix_web::{FromRequest, HttpRequest};
use futures::future; use futures_util::future::{ready, Ready};
use super::config::AuthExtractorConfig; use super::config::AuthExtractorConfig;
use super::errors::AuthenticationError; use super::errors::AuthenticationError;
@ -104,14 +104,14 @@ impl BearerAuth {
impl FromRequest for BearerAuth { impl FromRequest for BearerAuth {
type Config = Config; type Config = Config;
type Future = future::Ready<Result<Self, Self::Error>>; type Future = Ready<Result<Self, Self::Error>>;
type Error = AuthenticationError<bearer::Bearer>; type Error = AuthenticationError<bearer::Bearer>;
fn from_request( fn from_request(
req: &HttpRequest, req: &HttpRequest,
_payload: &mut Payload, _payload: &mut Payload,
) -> <Self as FromRequest>::Future { ) -> <Self as FromRequest>::Future {
future::ready( ready(
authorization::Authorization::<authorization::Bearer>::parse(req) authorization::Authorization::<authorization::Bearer>::parse(req)
.map(|auth| BearerAuth(auth.into_scheme())) .map(|auth| BearerAuth(auth.into_scheme()))
.map_err(|_| { .map_err(|_| {
@ -127,11 +127,11 @@ impl FromRequest for BearerAuth {
} }
impl AuthExtractor for BearerAuth { impl AuthExtractor for BearerAuth {
type Future = future::Ready<Result<Self, Self::Error>>; type Future = Ready<Result<Self, Self::Error>>;
type Error = AuthenticationError<bearer::Bearer>; type Error = AuthenticationError<bearer::Bearer>;
fn from_service_request(req: &ServiceRequest) -> Self::Future { fn from_service_request(req: &ServiceRequest) -> Self::Future {
future::ready( ready(
authorization::Authorization::<authorization::Bearer>::parse(req) authorization::Authorization::<authorization::Bearer>::parse(req)
.map(|auth| BearerAuth(auth.into_scheme())) .map(|auth| BearerAuth(auth.into_scheme()))
.map_err(|_| { .map_err(|_| {

View File

@ -2,7 +2,7 @@
use actix_web::dev::ServiceRequest; use actix_web::dev::ServiceRequest;
use actix_web::Error; use actix_web::Error;
use futures::future::Future; use std::future::Future;
pub mod basic; pub mod basic;
pub mod bearer; pub mod bearer;

View File

@ -1,5 +1,6 @@
//! HTTP Authentication middleware. //! HTTP Authentication middleware.
use std::future::Future;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::pin::Pin; use std::pin::Pin;
use std::sync::Arc; use std::sync::Arc;
@ -7,9 +8,9 @@ use std::sync::Arc;
use actix_service::{Service, Transform}; use actix_service::{Service, Transform};
use actix_web::dev::{ServiceRequest, ServiceResponse}; use actix_web::dev::{ServiceRequest, ServiceResponse};
use actix_web::Error; use actix_web::Error;
use futures::future::{self, Future, FutureExt, LocalBoxFuture, TryFutureExt}; use futures_util::future::{self, FutureExt, LocalBoxFuture, TryFutureExt};
use futures::lock::Mutex; use futures_util::lock::Mutex;
use futures::task::{Context, Poll}; use futures_util::task::{Context, Poll};
use crate::extractors::{basic, bearer, AuthExtractor}; use crate::extractors::{basic, bearer, AuthExtractor};
@ -239,7 +240,7 @@ where
.f .f
.as_mut() .as_mut()
.expect("Extraction future should be initialized at this point"); .expect("Extraction future should be initialized at this point");
let credentials = futures::ready!(Future::poll(f.as_mut(), ctx))?; let credentials = futures_util::ready!(Future::poll(f.as_mut(), ctx))?;
let req = self.req.take().expect("Extract future was polled twice!"); let req = self.req.take().expect("Extract future was polled twice!");
Poll::Ready(Ok((req, credentials))) Poll::Ready(Ok((req, credentials)))