mirror of
https://github.com/actix/actix-web.git
synced 2024-11-22 09:31:10 +00:00
web: Minimize futures
dependencies
This commit is contained in:
parent
d7abbff3b0
commit
a98e53ecb8
29 changed files with 60 additions and 51 deletions
|
@ -84,7 +84,9 @@ awc = { version = "2.0.0-alpha.1", default-features = false }
|
|||
bytes = "0.5.3"
|
||||
derive_more = "0.99.2"
|
||||
encoding_rs = "0.8"
|
||||
futures = "0.3.1"
|
||||
futures-channel = { version = "0.3.5", default-features = false }
|
||||
futures-core = { version = "0.3.5", default-features = false }
|
||||
futures-util = { version = "0.3.5", default-features = false }
|
||||
fxhash = "0.2.1"
|
||||
log = "0.4"
|
||||
mime = "0.3"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use actix_web::{test, web, App, HttpResponse};
|
||||
use awc::Client;
|
||||
use criterion::{criterion_group, criterion_main, Criterion};
|
||||
use futures::future::join_all;
|
||||
use futures_util::future::join_all;
|
||||
|
||||
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||
Hello World Hello World Hello World Hello World Hello World \
|
||||
|
|
|
@ -10,7 +10,7 @@ use actix_service::boxed::{self, BoxServiceFactory};
|
|||
use actix_service::{
|
||||
apply, apply_fn_factory, IntoServiceFactory, ServiceFactory, Transform,
|
||||
};
|
||||
use futures::future::FutureExt;
|
||||
use futures_util::future::FutureExt;
|
||||
|
||||
use crate::app_service::{AppEntry, AppInit, AppRoutingFactory};
|
||||
use crate::config::ServiceConfig;
|
||||
|
@ -474,7 +474,7 @@ where
|
|||
mod tests {
|
||||
use actix_service::Service;
|
||||
use bytes::Bytes;
|
||||
use futures::future::{ok, err};
|
||||
use futures_util::future::{ok, err};
|
||||
|
||||
use super::*;
|
||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||
|
|
|
@ -9,7 +9,7 @@ use actix_http::{Extensions, Request, Response};
|
|||
use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url};
|
||||
use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
||||
use actix_service::{fn_service, Service, ServiceFactory};
|
||||
use futures::future::{join_all, ok, FutureExt, LocalBoxFuture};
|
||||
use futures_util::future::{join_all, ok, FutureExt, LocalBoxFuture};
|
||||
|
||||
use crate::config::{AppConfig, AppService};
|
||||
use crate::data::{DataFactory, FnDataFactory};
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
|
||||
use actix_http::error::{Error, ErrorInternalServerError};
|
||||
use actix_http::Extensions;
|
||||
use futures::future::{err, ok, LocalBoxFuture, Ready};
|
||||
use futures_util::future::{err, ok, LocalBoxFuture, Ready};
|
||||
|
||||
use crate::dev::Payload;
|
||||
use crate::extract::FromRequest;
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::pin::Pin;
|
|||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_http::error::Error;
|
||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
|
||||
use crate::dev::Payload;
|
||||
use crate::request::HttpRequest;
|
||||
|
@ -50,7 +50,7 @@ pub trait FromRequest: Sized {
|
|||
/// ```rust
|
||||
/// use actix_web::{web, dev, App, Error, HttpRequest, FromRequest};
|
||||
/// use actix_web::error::ErrorBadRequest;
|
||||
/// use futures::future::{ok, err, Ready};
|
||||
/// use futures_util::future::{ok, err, Ready};
|
||||
/// use serde_derive::Deserialize;
|
||||
/// use rand;
|
||||
///
|
||||
|
@ -122,7 +122,7 @@ where
|
|||
/// ```rust
|
||||
/// use actix_web::{web, dev, App, Result, Error, HttpRequest, FromRequest};
|
||||
/// use actix_web::error::ErrorBadRequest;
|
||||
/// use futures::future::{ok, err, Ready};
|
||||
/// use futures_util::future::{ok, err, Ready};
|
||||
/// use serde_derive::Deserialize;
|
||||
/// use rand;
|
||||
///
|
||||
|
|
|
@ -6,8 +6,8 @@ use std::task::{Context, Poll};
|
|||
|
||||
use actix_http::{Error, Response};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ok, Ready};
|
||||
use futures::ready;
|
||||
use futures_util::future::{ok, Ready};
|
||||
use futures_util::ready;
|
||||
use pin_project::pin_project;
|
||||
|
||||
use crate::extract::FromRequest;
|
||||
|
|
|
@ -11,7 +11,7 @@ use actix_http::encoding::Encoder;
|
|||
use actix_http::http::header::{ContentEncoding, ACCEPT_ENCODING};
|
||||
use actix_http::Error;
|
||||
use actix_service::{Service, Transform};
|
||||
use futures::future::{ok, Ready};
|
||||
use futures_util::future::{ok, Ready};
|
||||
use pin_project::pin_project;
|
||||
|
||||
use crate::dev::BodyEncoding;
|
||||
|
@ -133,7 +133,7 @@ where
|
|||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
|
||||
match futures::ready!(this.fut.poll(cx)) {
|
||||
match futures_util::ready!(this.fut.poll(cx)) {
|
||||
Ok(resp) => {
|
||||
let enc = if let Some(enc) = resp.response().get_encoding() {
|
||||
enc
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use futures::future::{ok, Either, FutureExt, LocalBoxFuture};
|
||||
use futures_util::future::{ok, Either, FutureExt, LocalBoxFuture};
|
||||
|
||||
/// `Middleware` for conditionally enables another middleware.
|
||||
/// The controlled middleware must not change the `Service` interfaces.
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::rc::Rc;
|
|||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
|
||||
use crate::http::header::{HeaderName, HeaderValue, CONTENT_TYPE};
|
||||
use crate::http::{Error as HttpError, HeaderMap};
|
||||
|
@ -157,7 +157,7 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::IntoService;
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
use super::*;
|
||||
use crate::dev::ServiceRequest;
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
|||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use fxhash::FxHashMap;
|
||||
|
||||
use crate::dev::{ServiceRequest, ServiceResponse};
|
||||
|
@ -147,7 +147,7 @@ where
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::IntoService;
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
use super::*;
|
||||
use crate::http::{header::CONTENT_TYPE, HeaderValue, StatusCode};
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::task::{Context, Poll};
|
|||
|
||||
use actix_service::{Service, Transform};
|
||||
use bytes::Bytes;
|
||||
use futures::future::{ok, Ready};
|
||||
use futures_util::future::{ok, Ready};
|
||||
use log::debug;
|
||||
use regex::Regex;
|
||||
use time::OffsetDateTime;
|
||||
|
@ -216,7 +216,7 @@ where
|
|||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.project();
|
||||
|
||||
let res = match futures::ready!(this.fut.poll(cx)) {
|
||||
let res = match futures_util::ready!(this.fut.poll(cx)) {
|
||||
Ok(res) => res,
|
||||
Err(e) => return Poll::Ready(Err(e)),
|
||||
};
|
||||
|
@ -506,7 +506,7 @@ impl<'a> fmt::Display for FormatDisplay<'a> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_service::{IntoService, Service, Transform};
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
use super::*;
|
||||
use crate::http::{header, StatusCode};
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::task::{Context, Poll};
|
|||
use actix_http::http::{PathAndQuery, Uri};
|
||||
use actix_service::{Service, Transform};
|
||||
use bytes::Bytes;
|
||||
use futures::future::{ok, Ready};
|
||||
use futures_util::future::{ok, Ready};
|
||||
use regex::Regex;
|
||||
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{fmt, net};
|
|||
use actix_http::http::{HeaderMap, Method, Uri, Version};
|
||||
use actix_http::{Error, Extensions, HttpMessage, Message, Payload, RequestHead};
|
||||
use actix_router::{Path, Url};
|
||||
use futures::future::{ok, Ready};
|
||||
use futures_util::future::{ok, Ready};
|
||||
use tinyvec::TinyVec;
|
||||
|
||||
use crate::config::AppConfig;
|
||||
|
|
|
@ -11,7 +11,7 @@ use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
|||
use actix_service::{
|
||||
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
||||
};
|
||||
use futures::future::{ok, Either, LocalBoxFuture, Ready};
|
||||
use futures_util::future::{ok, Either, LocalBoxFuture, Ready};
|
||||
|
||||
use crate::data::Data;
|
||||
use crate::dev::{insert_slash, AppService, HttpServiceFactory, ResourceDef};
|
||||
|
@ -588,7 +588,7 @@ mod tests {
|
|||
|
||||
use actix_rt::time::delay_for;
|
||||
use actix_service::Service;
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||
use crate::middleware::DefaultHeaders;
|
||||
|
|
|
@ -10,8 +10,8 @@ use actix_http::http::{
|
|||
};
|
||||
use actix_http::{Error, Response, ResponseBuilder};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::future::{err, ok, Either as EitherFuture, Ready};
|
||||
use futures::ready;
|
||||
use futures_util::future::{err, ok, Either as EitherFuture, Ready};
|
||||
use futures_util::ready;
|
||||
use pin_project::{pin_project, project};
|
||||
|
||||
use crate::request::HttpRequest;
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::task::{Context, Poll};
|
|||
|
||||
use actix_http::{http::Method, Error};
|
||||
use actix_service::{Service, ServiceFactory};
|
||||
use futures::future::{ready, FutureExt, LocalBoxFuture};
|
||||
use futures_util::future::{ready, FutureExt, LocalBoxFuture};
|
||||
|
||||
use crate::extract::FromRequest;
|
||||
use crate::guard::{self, Guard};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::cell::RefCell;
|
||||
use std::fmt;
|
||||
use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
use std::task::{Context, Poll};
|
||||
|
@ -10,7 +11,7 @@ use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
|||
use actix_service::{
|
||||
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
||||
};
|
||||
use futures::future::{ok, Either, Future, LocalBoxFuture, Ready};
|
||||
use futures_util::future::{ok, Either, LocalBoxFuture, Ready};
|
||||
|
||||
use crate::config::ServiceConfig;
|
||||
use crate::data::Data;
|
||||
|
@ -666,7 +667,7 @@ impl ServiceFactory for ScopeEndpoint {
|
|||
mod tests {
|
||||
use actix_service::Service;
|
||||
use bytes::Bytes;
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
use crate::dev::{Body, ResponseBody};
|
||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||
|
|
|
@ -13,7 +13,7 @@ use actix_http::Protocol;
|
|||
#[cfg(unix)]
|
||||
use actix_service::pipeline_factory;
|
||||
#[cfg(unix)]
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
#[cfg(feature = "openssl")]
|
||||
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
||||
|
|
|
@ -536,7 +536,7 @@ mod tests {
|
|||
use crate::test::{init_service, TestRequest};
|
||||
use crate::{guard, http, web, App, HttpResponse};
|
||||
use actix_service::Service;
|
||||
use futures::future::ok;
|
||||
use futures_util::future::ok;
|
||||
|
||||
#[test]
|
||||
fn test_service_request() {
|
||||
|
|
|
@ -18,8 +18,9 @@ use actix_service::{
|
|||
use awc::error::PayloadError;
|
||||
use awc::{Client, ClientRequest, ClientResponse, Connector};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::future::ok;
|
||||
use futures::stream::{Stream, StreamExt};
|
||||
use futures_core::Stream;
|
||||
use futures_util::future::ok;
|
||||
use futures_util::StreamExt;
|
||||
use net2::TcpBuilder;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
|
|
|
@ -9,8 +9,8 @@ use std::{fmt, ops};
|
|||
use actix_http::{Error, HttpMessage, Payload, Response};
|
||||
use bytes::BytesMut;
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures::StreamExt;
|
||||
use futures_util::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures_util::StreamExt;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::task::{Context, Poll};
|
|||
use std::{fmt, ops};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures::StreamExt;
|
||||
use futures_util::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures_util::StreamExt;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{fmt, ops};
|
|||
|
||||
use actix_http::error::{Error, ErrorNotFound};
|
||||
use actix_router::PathDeserializer;
|
||||
use futures::future::{ready, Ready};
|
||||
use futures_util::future::{ready, Ready};
|
||||
use serde::de;
|
||||
|
||||
use crate::dev::Payload;
|
||||
|
|
|
@ -8,8 +8,9 @@ use actix_http::error::{Error, ErrorBadRequest, PayloadError};
|
|||
use actix_http::HttpMessage;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use encoding_rs::UTF_8;
|
||||
use futures::future::{err, ok, Either, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures::{Stream, StreamExt};
|
||||
use futures_core::stream::Stream;
|
||||
use futures_util::future::{err, ok, Either, FutureExt, LocalBoxFuture, Ready};
|
||||
use futures_util::StreamExt;
|
||||
use mime::Mime;
|
||||
|
||||
use crate::dev;
|
||||
|
@ -22,9 +23,10 @@ use crate::request::HttpRequest;
|
|||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use futures::{Future, Stream, StreamExt};
|
||||
/// use actix_web::{web, error, App, Error, HttpResponse};
|
||||
///
|
||||
/// use std::future::Future;
|
||||
/// use futures_core::stream::Stream;
|
||||
/// use futures_util::StreamExt;
|
||||
/// /// extract binary data from request
|
||||
/// async fn index(mut body: web::Payload) -> Result<HttpResponse, Error>
|
||||
/// {
|
||||
|
@ -70,8 +72,10 @@ impl Stream for Payload {
|
|||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use futures::{Future, Stream, StreamExt};
|
||||
/// use actix_web::{web, error, App, Error, HttpResponse};
|
||||
/// use std::future::Future;
|
||||
/// use futures_core::stream::Stream;
|
||||
/// use futures_util::StreamExt;
|
||||
///
|
||||
/// /// extract binary data from request
|
||||
/// async fn index(mut body: web::Payload) -> Result<HttpResponse, Error>
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
|||
use std::{fmt, ops};
|
||||
|
||||
use actix_http::error::Error;
|
||||
use futures::future::{err, ok, Ready};
|
||||
use futures_util::future::{err, ok, Ready};
|
||||
use serde::de;
|
||||
|
||||
use crate::dev::Payload;
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::task::{Context, Poll};
|
|||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use futures::Stream;
|
||||
use futures_util::stream::Stream;
|
||||
|
||||
use crate::dev::Payload;
|
||||
use crate::error::{PayloadError, ReadlinesError};
|
||||
|
@ -172,7 +172,7 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use futures::stream::StreamExt;
|
||||
use futures_util::stream::StreamExt;
|
||||
|
||||
use super::*;
|
||||
use crate::test::TestRequest;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
//! Essentials helper functions and types for application registration.
|
||||
use actix_http::http::Method;
|
||||
use actix_router::IntoPattern;
|
||||
use futures::Future;
|
||||
use std::future::Future;
|
||||
|
||||
pub use actix_http::Response as HttpResponse;
|
||||
pub use bytes::{Bytes, BytesMut};
|
||||
pub use futures::channel::oneshot::Canceled;
|
||||
pub use futures_channel::oneshot::Canceled;
|
||||
|
||||
use crate::error::BlockingError;
|
||||
use crate::extract::FromRequest;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::future::Future;
|
||||
use std::io::{Read, Write};
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
@ -11,7 +12,7 @@ use bytes::Bytes;
|
|||
use flate2::read::GzDecoder;
|
||||
use flate2::write::{GzEncoder, ZlibDecoder, ZlibEncoder};
|
||||
use flate2::Compression;
|
||||
use futures::{ready, Future};
|
||||
use futures_util::ready;
|
||||
use rand::{distributions::Alphanumeric, Rng};
|
||||
|
||||
use actix_web::dev::BodyEncoding;
|
||||
|
@ -56,7 +57,7 @@ impl TestBody {
|
|||
}
|
||||
}
|
||||
|
||||
impl futures::Stream for TestBody {
|
||||
impl futures_core::stream::Stream for TestBody {
|
||||
type Item = Result<Bytes, Error>;
|
||||
|
||||
fn poll_next(
|
||||
|
|
Loading…
Reference in a new issue