mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 16:55:08 +02:00
upgrade to tokio 0.2
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
//! Middleware for setting default response headers
|
||||
use std::convert::TryFrom;
|
||||
use std::rc::Rc;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
@ -6,7 +7,7 @@ use actix_service::{Service, Transform};
|
||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||
|
||||
use crate::http::header::{HeaderName, HeaderValue, CONTENT_TYPE};
|
||||
use crate::http::{HeaderMap, HttpTryFrom};
|
||||
use crate::http::{Error as HttpError, HeaderMap};
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
use crate::Error;
|
||||
|
||||
@ -58,8 +59,10 @@ impl DefaultHeaders {
|
||||
#[inline]
|
||||
pub fn header<K, V>(mut self, key: K, value: V) -> Self
|
||||
where
|
||||
HeaderName: HttpTryFrom<K>,
|
||||
HeaderValue: HttpTryFrom<V>,
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
|
||||
HeaderValue: TryFrom<V>,
|
||||
<HeaderValue as TryFrom<V>>::Error: Into<HttpError>,
|
||||
{
|
||||
#[allow(clippy::match_wild_err_arm)]
|
||||
match HeaderName::try_from(key) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
//! Request logging middleware
|
||||
use std::collections::HashSet;
|
||||
use std::convert::TryFrom;
|
||||
use std::env;
|
||||
use std::fmt::{self, Display, Formatter};
|
||||
use std::future::Future;
|
||||
@ -17,7 +18,7 @@ use time;
|
||||
|
||||
use crate::dev::{BodySize, MessageBody, ResponseBody};
|
||||
use crate::error::{Error, Result};
|
||||
use crate::http::{HeaderName, HttpTryFrom, StatusCode};
|
||||
use crate::http::{HeaderName, StatusCode};
|
||||
use crate::service::{ServiceRequest, ServiceResponse};
|
||||
use crate::HttpResponse;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
//! `Middleware` to normalize request's URI
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_http::http::{HttpTryFrom, PathAndQuery, Uri};
|
||||
use actix_http::http::{PathAndQuery, Uri};
|
||||
use actix_service::{Service, Transform};
|
||||
use bytes::Bytes;
|
||||
use futures::future::{ok, Ready};
|
||||
@ -74,7 +74,6 @@ where
|
||||
|
||||
fn call(&mut self, mut req: ServiceRequest) -> Self::Future {
|
||||
let head = req.head_mut();
|
||||
|
||||
let path = head.uri.path();
|
||||
let original_len = path.len();
|
||||
let path = self.merge_slash.replace_all(path, "/");
|
||||
@ -86,9 +85,10 @@ where
|
||||
let path = if let Some(q) = pq.query() {
|
||||
Bytes::from(format!("{}?{}", path, q))
|
||||
} else {
|
||||
Bytes::from(path.as_ref())
|
||||
Bytes::copy_from_slice(path.as_bytes())
|
||||
};
|
||||
parts.path_and_query = Some(PathAndQuery::try_from(path).unwrap());
|
||||
parts.path_and_query = Some(PathAndQuery::from_maybe_shared(path).unwrap());
|
||||
drop(head);
|
||||
|
||||
let uri = Uri::from_parts(parts).unwrap();
|
||||
req.match_info_mut().get_mut().update(&uri);
|
||||
|
Reference in New Issue
Block a user