mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 22:49:21 +02:00
decompress payload in cpu threadpool
This commit is contained in:
22
src/error.rs
22
src/error.rs
@ -1,6 +1,4 @@
|
||||
//! Error and Result module
|
||||
use std::fmt;
|
||||
|
||||
pub use actix_http::error::*;
|
||||
use derive_more::{Display, From};
|
||||
use serde_json::error::Error as JsonError;
|
||||
@ -26,26 +24,6 @@ pub enum UrlGenerationError {
|
||||
/// `InternalServerError` for `UrlGeneratorError`
|
||||
impl ResponseError for UrlGenerationError {}
|
||||
|
||||
/// Blocking operation execution error
|
||||
#[derive(Debug, Display)]
|
||||
pub enum BlockingError<E: fmt::Debug> {
|
||||
#[display(fmt = "{:?}", _0)]
|
||||
Error(E),
|
||||
#[display(fmt = "Thread pool is gone")]
|
||||
Canceled,
|
||||
}
|
||||
|
||||
impl<E: fmt::Debug> ResponseError for BlockingError<E> {}
|
||||
|
||||
impl<E: fmt::Debug> From<actix_threadpool::BlockingError<E>> for BlockingError<E> {
|
||||
fn from(err: actix_threadpool::BlockingError<E>) -> Self {
|
||||
match err {
|
||||
actix_threadpool::BlockingError::Error(e) => BlockingError::Error(e),
|
||||
actix_threadpool::BlockingError::Canceled => BlockingError::Canceled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of errors that can occur during parsing urlencoded payloads
|
||||
#[derive(Debug, Display, From)]
|
||||
pub enum UrlencodedError {
|
||||
|
@ -162,6 +162,7 @@ pub mod dev {
|
||||
pub mod web {
|
||||
//! Various types
|
||||
use actix_http::{http::Method, Response};
|
||||
use actix_service::{fn_transform, Service, Transform};
|
||||
use futures::{Future, IntoFuture};
|
||||
|
||||
pub use actix_http::Response as HttpResponse;
|
||||
@ -174,6 +175,7 @@ pub mod web {
|
||||
use crate::responder::Responder;
|
||||
use crate::route::Route;
|
||||
use crate::scope::Scope;
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
|
||||
pub use crate::data::{Data, RouteData};
|
||||
pub use crate::request::HttpRequest;
|
||||
@ -341,10 +343,6 @@ pub mod web {
|
||||
actix_threadpool::run(f).from_err()
|
||||
}
|
||||
|
||||
use actix_service::{fn_transform, Service, Transform};
|
||||
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
|
||||
/// Create middleare
|
||||
pub fn md<F, R, S, P, B>(
|
||||
f: F,
|
||||
|
@ -70,7 +70,7 @@ where
|
||||
|
||||
fn call(&mut self, req: ServiceRequest<P>) -> Self::Future {
|
||||
let (req, payload) = req.into_parts();
|
||||
let payload = Decoder::from_headers(req.headers(), payload);
|
||||
let payload = Decoder::from_headers(payload, req.headers());
|
||||
ok(ServiceRequest::from_parts(req, Payload::Stream(payload)))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user