mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-01 00:44:26 +02:00
remove actix_http::http
module (#2488)
This commit is contained in:
@ -353,7 +353,7 @@ where
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{middleware, web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
/// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
|
||||
///
|
||||
/// async fn index() -> &'static str {
|
||||
/// "Welcome!"
|
||||
@ -410,7 +410,7 @@ where
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
/// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
|
||||
///
|
||||
/// async fn index() -> &'static str {
|
||||
/// "Welcome!"
|
||||
@ -494,7 +494,10 @@ mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||
use crate::http::{
|
||||
header::{self, HeaderValue},
|
||||
Method, StatusCode,
|
||||
};
|
||||
use crate::middleware::DefaultHeaders;
|
||||
use crate::service::ServiceRequest;
|
||||
use crate::test::{call_service, init_service, read_body, try_init_service, TestRequest};
|
||||
|
@ -7,7 +7,7 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use actix_http::http::{Method, Uri};
|
||||
use actix_http::{Method, Uri};
|
||||
use actix_utils::future::{ok, Ready};
|
||||
use futures_core::ready;
|
||||
use pin_project_lite::pin_project;
|
||||
@ -402,7 +402,7 @@ mod tuple_from_req {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::http::header;
|
||||
use actix_http::header;
|
||||
use bytes::Bytes;
|
||||
use serde::Deserialize;
|
||||
|
||||
|
36
src/guard.rs
36
src/guard.rs
@ -24,13 +24,13 @@
|
||||
//! );
|
||||
//! }
|
||||
//! ```
|
||||
#![allow(non_snake_case)]
|
||||
use std::convert::TryFrom;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
|
||||
use actix_http::http::{self, header, uri::Uri};
|
||||
use actix_http::RequestHead;
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::{convert::TryFrom, ops::Deref};
|
||||
|
||||
use actix_http::{header, uri::Uri, Method as HttpMethod, RequestHead};
|
||||
|
||||
/// Trait defines resource guards. Guards are used for route selection.
|
||||
///
|
||||
@ -186,7 +186,7 @@ impl Guard for NotGuard {
|
||||
|
||||
/// HTTP method guard.
|
||||
#[doc(hidden)]
|
||||
pub struct MethodGuard(http::Method);
|
||||
pub struct MethodGuard(HttpMethod);
|
||||
|
||||
impl Guard for MethodGuard {
|
||||
fn check(&self, request: &RequestHead) -> bool {
|
||||
@ -196,51 +196,51 @@ impl Guard for MethodGuard {
|
||||
|
||||
/// Guard to match *GET* HTTP method.
|
||||
pub fn Get() -> MethodGuard {
|
||||
MethodGuard(http::Method::GET)
|
||||
MethodGuard(HttpMethod::GET)
|
||||
}
|
||||
|
||||
/// Predicate to match *POST* HTTP method.
|
||||
pub fn Post() -> MethodGuard {
|
||||
MethodGuard(http::Method::POST)
|
||||
MethodGuard(HttpMethod::POST)
|
||||
}
|
||||
|
||||
/// Predicate to match *PUT* HTTP method.
|
||||
pub fn Put() -> MethodGuard {
|
||||
MethodGuard(http::Method::PUT)
|
||||
MethodGuard(HttpMethod::PUT)
|
||||
}
|
||||
|
||||
/// Predicate to match *DELETE* HTTP method.
|
||||
pub fn Delete() -> MethodGuard {
|
||||
MethodGuard(http::Method::DELETE)
|
||||
MethodGuard(HttpMethod::DELETE)
|
||||
}
|
||||
|
||||
/// Predicate to match *HEAD* HTTP method.
|
||||
pub fn Head() -> MethodGuard {
|
||||
MethodGuard(http::Method::HEAD)
|
||||
MethodGuard(HttpMethod::HEAD)
|
||||
}
|
||||
|
||||
/// Predicate to match *OPTIONS* HTTP method.
|
||||
pub fn Options() -> MethodGuard {
|
||||
MethodGuard(http::Method::OPTIONS)
|
||||
MethodGuard(HttpMethod::OPTIONS)
|
||||
}
|
||||
|
||||
/// Predicate to match *CONNECT* HTTP method.
|
||||
pub fn Connect() -> MethodGuard {
|
||||
MethodGuard(http::Method::CONNECT)
|
||||
MethodGuard(HttpMethod::CONNECT)
|
||||
}
|
||||
|
||||
/// Predicate to match *PATCH* HTTP method.
|
||||
pub fn Patch() -> MethodGuard {
|
||||
MethodGuard(http::Method::PATCH)
|
||||
MethodGuard(HttpMethod::PATCH)
|
||||
}
|
||||
|
||||
/// Predicate to match *TRACE* HTTP method.
|
||||
pub fn Trace() -> MethodGuard {
|
||||
MethodGuard(http::Method::TRACE)
|
||||
MethodGuard(HttpMethod::TRACE)
|
||||
}
|
||||
|
||||
/// Predicate to match specified HTTP method.
|
||||
pub fn Method(method: http::Method) -> MethodGuard {
|
||||
pub fn Method(method: HttpMethod) -> MethodGuard {
|
||||
MethodGuard(method)
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ impl Guard for HostGuard {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::http::{header, Method};
|
||||
use actix_http::{header, Method};
|
||||
|
||||
use super::*;
|
||||
use crate::test::TestRequest;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use actix_http::http::Method;
|
||||
use actix_http::Method;
|
||||
|
||||
use crate::http::header;
|
||||
|
||||
|
@ -6,7 +6,7 @@ macro_rules! common_header_test_module {
|
||||
|
||||
use ::core::str;
|
||||
|
||||
use ::actix_http::{http::Method, test};
|
||||
use ::actix_http::{Method, test};
|
||||
use ::mime::*;
|
||||
|
||||
use $crate::http::header::{self, *};
|
||||
|
@ -15,7 +15,7 @@ use bytes::{Bytes, BytesMut};
|
||||
// - header map
|
||||
// - the few typed headers from actix-http
|
||||
// - header parsing utils
|
||||
pub use actix_http::http::header::*;
|
||||
pub use actix_http::header::*;
|
||||
|
||||
mod accept;
|
||||
mod accept_charset;
|
||||
|
@ -1,2 +1,5 @@
|
||||
//! Various HTTP related types.
|
||||
|
||||
pub mod header;
|
||||
pub use actix_http::http::*;
|
||||
|
||||
pub use actix_http::{uri, ConnectionType, Error, Method, StatusCode, Uri, Version};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::{
|
||||
cmp,
|
||||
convert::TryFrom,
|
||||
convert::TryFrom as _,
|
||||
future::Future,
|
||||
marker::PhantomData,
|
||||
pin::Pin,
|
||||
@ -12,7 +12,7 @@ use std::{
|
||||
use actix_http::{
|
||||
body::{EitherBody, MessageBody},
|
||||
encoding::Encoder,
|
||||
http::header::{ContentEncoding, ACCEPT_ENCODING},
|
||||
header::{ContentEncoding, ACCEPT_ENCODING},
|
||||
StatusCode,
|
||||
};
|
||||
use actix_service::{Service, Transform};
|
||||
|
@ -102,7 +102,10 @@ mod tests {
|
||||
use crate::{
|
||||
dev::{ServiceRequest, ServiceResponse},
|
||||
error::Result,
|
||||
http::{header::CONTENT_TYPE, HeaderValue, StatusCode},
|
||||
http::{
|
||||
header::{HeaderValue, CONTENT_TYPE},
|
||||
StatusCode,
|
||||
},
|
||||
middleware::err_handlers::*,
|
||||
test::{self, TestRequest},
|
||||
HttpResponse,
|
||||
|
@ -9,16 +9,14 @@ use std::{
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use actix_http::error::HttpError;
|
||||
use actix_utils::future::{ready, Ready};
|
||||
use futures_core::ready;
|
||||
use pin_project_lite::pin_project;
|
||||
|
||||
use crate::{
|
||||
dev::{Service, Transform},
|
||||
http::{
|
||||
header::{HeaderName, HeaderValue, CONTENT_TYPE},
|
||||
Error as HttpError, HeaderMap,
|
||||
},
|
||||
http::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE},
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
Error,
|
||||
};
|
||||
|
@ -37,19 +37,20 @@ type ErrorHandler<B> = dyn Fn(ServiceResponse<B>) -> Result<ErrorHandlerResponse
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use actix_web::middleware::{ErrorHandlers, ErrorHandlerResponse};
|
||||
/// use actix_web::{web, http, dev, App, HttpRequest, HttpResponse, Result};
|
||||
/// use actix_web::{web, dev, App, HttpRequest, HttpResponse, Result};
|
||||
/// use actix_web::http::{StatusCode, header};
|
||||
///
|
||||
/// fn render_500<B>(mut res: dev::ServiceResponse<B>) -> Result<ErrorHandlerResponse<B>> {
|
||||
/// res.response_mut()
|
||||
/// .headers_mut()
|
||||
/// .insert(http::header::CONTENT_TYPE, http::HeaderValue::from_static("Error"));
|
||||
/// .insert(header::CONTENT_TYPE, header::HeaderValue::from_static("Error"));
|
||||
/// Ok(ErrorHandlerResponse::Response(res))
|
||||
/// }
|
||||
///
|
||||
/// let app = App::new()
|
||||
/// .wrap(
|
||||
/// ErrorHandlers::new()
|
||||
/// .handler(http::StatusCode::INTERNAL_SERVER_ERROR, render_500),
|
||||
/// .handler(StatusCode::INTERNAL_SERVER_ERROR, render_500),
|
||||
/// )
|
||||
/// .service(web::resource("/test")
|
||||
/// .route(web::get().to(|| HttpResponse::Ok()))
|
||||
@ -182,7 +183,10 @@ mod tests {
|
||||
use futures_util::future::FutureExt as _;
|
||||
|
||||
use super::*;
|
||||
use crate::http::{header::CONTENT_TYPE, HeaderValue, StatusCode};
|
||||
use crate::http::{
|
||||
header::{HeaderValue, CONTENT_TYPE},
|
||||
StatusCode,
|
||||
};
|
||||
use crate::test::{self, TestRequest};
|
||||
use crate::HttpResponse;
|
||||
|
||||
|
@ -23,7 +23,7 @@ use time::{format_description::well_known::Rfc3339, OffsetDateTime};
|
||||
|
||||
use crate::{
|
||||
body::{BodySize, MessageBody},
|
||||
http::HeaderName,
|
||||
http::header::HeaderName,
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
Error, HttpResponse, Result,
|
||||
};
|
||||
@ -126,7 +126,8 @@ impl Logger {
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// # use actix_web::{http::HeaderValue, middleware::Logger};
|
||||
/// # use actix_web::http::{header::HeaderValue};
|
||||
/// # use actix_web::middleware::Logger;
|
||||
/// # fn parse_jwt_id (_req: Option<&HeaderValue>) -> String { "jwt_uid".to_owned() }
|
||||
/// Logger::new("example %{JWT_ID}xi")
|
||||
/// .custom_request_replace("JWT_ID", |req| parse_jwt_id(req.headers().get("Authorization")));
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! For middleware documentation, see [`NormalizePath`].
|
||||
|
||||
use actix_http::http::{PathAndQuery, Uri};
|
||||
use actix_http::uri::{PathAndQuery, Uri};
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_utils::future::{ready, Ready};
|
||||
use bytes::Bytes;
|
||||
|
@ -6,8 +6,8 @@ use std::{
|
||||
};
|
||||
|
||||
use actix_http::{
|
||||
http::{HeaderMap, Method, Uri, Version},
|
||||
Extensions, HttpMessage, Message, Payload, RequestHead,
|
||||
header::HeaderMap, Extensions, HttpMessage, Message, Method, Payload, RequestHead, Uri,
|
||||
Version,
|
||||
};
|
||||
use actix_router::{Path, Url};
|
||||
use actix_utils::future::{ok, Ready};
|
||||
@ -266,7 +266,7 @@ impl HttpRequest {
|
||||
/// Load request cookies.
|
||||
#[cfg(feature = "cookies")]
|
||||
pub fn cookies(&self) -> Result<Ref<'_, Vec<Cookie<'static>>>, CookieParseError> {
|
||||
use actix_http::http::header::COOKIE;
|
||||
use actix_http::header::COOKIE;
|
||||
|
||||
if self.extensions().get::<Cookies>().is_none() {
|
||||
let mut cookies = Vec::new();
|
||||
|
@ -298,7 +298,7 @@ where
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
/// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
|
||||
///
|
||||
/// async fn index() -> &'static str {
|
||||
/// "Welcome!"
|
||||
@ -508,7 +508,10 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
guard,
|
||||
http::{header, HeaderValue, Method, StatusCode},
|
||||
http::{
|
||||
header::{self, HeaderValue},
|
||||
Method, StatusCode,
|
||||
},
|
||||
middleware::DefaultHeaders,
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
test::{call_service, init_service, TestRequest},
|
||||
|
@ -2,7 +2,10 @@ use std::borrow::Cow;
|
||||
|
||||
use actix_http::{
|
||||
body::{BoxBody, EitherBody, MessageBody},
|
||||
http::{header::IntoHeaderPair, Error as HttpError, HeaderMap, StatusCode},
|
||||
error::HttpError,
|
||||
header::HeaderMap,
|
||||
header::IntoHeaderPair,
|
||||
StatusCode,
|
||||
};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
@ -280,7 +283,10 @@ pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
error,
|
||||
http::{header::CONTENT_TYPE, HeaderValue, StatusCode},
|
||||
http::{
|
||||
header::{HeaderValue, CONTENT_TYPE},
|
||||
StatusCode,
|
||||
},
|
||||
test::{assert_body_eq, init_service, TestRequest},
|
||||
web, App,
|
||||
};
|
||||
|
@ -8,18 +8,16 @@ use std::{
|
||||
|
||||
use actix_http::{
|
||||
body::{BodyStream, BoxBody, MessageBody},
|
||||
http::{
|
||||
header::{self, HeaderName, IntoHeaderPair, IntoHeaderValue},
|
||||
ConnectionType, Error as HttpError, StatusCode,
|
||||
},
|
||||
Extensions, Response, ResponseHead,
|
||||
error::HttpError,
|
||||
header::{self, HeaderName, IntoHeaderPair, IntoHeaderValue},
|
||||
ConnectionType, Extensions, Response, ResponseHead, StatusCode,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use serde::Serialize;
|
||||
|
||||
#[cfg(feature = "cookies")]
|
||||
use actix_http::http::header::HeaderValue;
|
||||
use actix_http::header::HeaderValue;
|
||||
#[cfg(feature = "cookies")]
|
||||
use cookie::{Cookie, CookieJar};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! Status code based HTTP response builders.
|
||||
|
||||
use actix_http::http::StatusCode;
|
||||
use actix_http::StatusCode;
|
||||
|
||||
use crate::{HttpResponse, HttpResponseBuilder};
|
||||
|
||||
|
@ -9,15 +9,15 @@ use std::{
|
||||
|
||||
use actix_http::{
|
||||
body::{BoxBody, EitherBody, MessageBody},
|
||||
http::{header::HeaderMap, StatusCode},
|
||||
Extensions, Response, ResponseHead,
|
||||
header::HeaderMap,
|
||||
Extensions, Response, ResponseHead, StatusCode,
|
||||
};
|
||||
|
||||
#[cfg(feature = "cookies")]
|
||||
use {
|
||||
actix_http::http::{
|
||||
actix_http::{
|
||||
error::HttpError,
|
||||
header::{self, HeaderValue},
|
||||
Error as HttpError,
|
||||
},
|
||||
cookie::Cookie,
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use std::{future::Future, mem, rc::Rc};
|
||||
|
||||
use actix_http::http::Method;
|
||||
use actix_http::Method;
|
||||
use actix_service::{
|
||||
boxed::{self, BoxService},
|
||||
fn_service, Service, ServiceFactory, ServiceFactoryExt,
|
||||
|
@ -347,7 +347,7 @@ where
|
||||
/// ```
|
||||
/// use actix_service::Service;
|
||||
/// use actix_web::{web, App};
|
||||
/// use actix_web::http::{header::CONTENT_TYPE, HeaderValue};
|
||||
/// use actix_web::http::header::{CONTENT_TYPE, HeaderValue};
|
||||
///
|
||||
/// async fn index() -> &'static str {
|
||||
/// "Welcome!"
|
||||
@ -587,7 +587,10 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
guard,
|
||||
http::{header, HeaderValue, Method, StatusCode},
|
||||
http::{
|
||||
header::{self, HeaderValue},
|
||||
Method, StatusCode,
|
||||
},
|
||||
middleware::DefaultHeaders,
|
||||
service::{ServiceRequest, ServiceResponse},
|
||||
test::{assert_body_eq, call_service, init_service, read_body, TestRequest},
|
||||
|
@ -6,8 +6,9 @@ use std::{
|
||||
|
||||
use actix_http::{
|
||||
body::{BoxBody, EitherBody, MessageBody},
|
||||
http::{HeaderMap, Method, StatusCode, Uri, Version},
|
||||
Extensions, HttpMessage, Payload, PayloadStream, RequestHead, Response, ResponseHead,
|
||||
header::HeaderMap,
|
||||
Extensions, HttpMessage, Method, Payload, PayloadStream, RequestHead, Response,
|
||||
ResponseHead, StatusCode, Uri, Version,
|
||||
};
|
||||
use actix_router::{IntoPatterns, Path, Patterns, Resource, ResourceDef, Url};
|
||||
use actix_service::{
|
||||
|
@ -4,9 +4,8 @@ use std::{borrow::Cow, net::SocketAddr, rc::Rc};
|
||||
|
||||
pub use actix_http::test::TestBuffer;
|
||||
use actix_http::{
|
||||
http::{header::IntoHeaderPair, Method, StatusCode, Uri, Version},
|
||||
test::TestRequest as HttpTestRequest,
|
||||
Extensions, Request,
|
||||
header::IntoHeaderPair, test::TestRequest as HttpTestRequest, Extensions, Method, Request,
|
||||
StatusCode, Uri, Version,
|
||||
};
|
||||
use actix_router::{Path, ResourceDef, Url};
|
||||
use actix_service::{IntoService, IntoServiceFactory, Service, ServiceFactory};
|
||||
@ -547,7 +546,7 @@ impl TestRequest {
|
||||
|
||||
#[cfg(feature = "cookies")]
|
||||
{
|
||||
use actix_http::http::header::{HeaderValue, COOKIE};
|
||||
use actix_http::header::{HeaderValue, COOKIE};
|
||||
|
||||
let cookie: String = self
|
||||
.cookies
|
||||
|
@ -185,14 +185,12 @@ impl QueryConfig {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::http::StatusCode;
|
||||
use actix_http::StatusCode;
|
||||
use derive_more::Display;
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::*;
|
||||
use crate::error::InternalError;
|
||||
use crate::test::TestRequest;
|
||||
use crate::HttpResponse;
|
||||
use crate::{error::InternalError, test::TestRequest, HttpResponse};
|
||||
|
||||
#[derive(Deserialize, Debug, Display)]
|
||||
struct Id {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use std::{error::Error as StdError, future::Future};
|
||||
|
||||
use actix_http::http::Method;
|
||||
use actix_http::Method;
|
||||
use actix_router::IntoPatterns;
|
||||
pub use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
|
||||
|
Reference in New Issue
Block a user