mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
remove deprecated types and methods
This commit is contained in:
parent
ab4e889f96
commit
eefbe19651
@ -13,9 +13,6 @@ use router::{Resource, Router};
|
||||
use scope::Scope;
|
||||
use server::{HttpHandler, HttpHandlerTask, IntoHttpHandler, ServerSettings};
|
||||
|
||||
#[deprecated(since = "0.5.0", note = "please use `actix_web::App` instead")]
|
||||
pub type Application<S> = App<S>;
|
||||
|
||||
/// Application
|
||||
pub struct HttpApplication<S = ()> {
|
||||
state: Rc<S>,
|
||||
|
258
src/httpcodes.rs
258
src/httpcodes.rs
@ -1,237 +1,8 @@
|
||||
//! Basic http responses
|
||||
#![allow(non_upper_case_globals, deprecated)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
use http::StatusCode;
|
||||
|
||||
use body::Body;
|
||||
use error::Error;
|
||||
use handler::{Handler, Reply, Responder, RouteHandler};
|
||||
use httprequest::HttpRequest;
|
||||
use httpresponse::{HttpResponse, HttpResponseBuilder};
|
||||
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Ok()` instead")]
|
||||
pub const HttpOk: StaticResponse = StaticResponse(StatusCode::OK);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Created()` instead")]
|
||||
pub const HttpCreated: StaticResponse = StaticResponse(StatusCode::CREATED);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Accepted()` instead")]
|
||||
pub const HttpAccepted: StaticResponse = StaticResponse(StatusCode::ACCEPTED);
|
||||
#[deprecated(
|
||||
since = "0.5.0",
|
||||
note = "please use `HttpResponse::pNonAuthoritativeInformation()` instead"
|
||||
)]
|
||||
pub const HttpNonAuthoritativeInformation: StaticResponse =
|
||||
StaticResponse(StatusCode::NON_AUTHORITATIVE_INFORMATION);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::NoContent()` instead")]
|
||||
pub const HttpNoContent: StaticResponse = StaticResponse(StatusCode::NO_CONTENT);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::ResetContent()` instead")]
|
||||
pub const HttpResetContent: StaticResponse = StaticResponse(StatusCode::RESET_CONTENT);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::PartialContent()` instead"
|
||||
)]
|
||||
pub const HttpPartialContent: StaticResponse =
|
||||
StaticResponse(StatusCode::PARTIAL_CONTENT);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::MultiStatus()` instead")]
|
||||
pub const HttpMultiStatus: StaticResponse = StaticResponse(StatusCode::MULTI_STATUS);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::AlreadyReported()` instead"
|
||||
)]
|
||||
pub const HttpAlreadyReported: StaticResponse =
|
||||
StaticResponse(StatusCode::ALREADY_REPORTED);
|
||||
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::MultipleChoices()` instead"
|
||||
)]
|
||||
pub const HttpMultipleChoices: StaticResponse =
|
||||
StaticResponse(StatusCode::MULTIPLE_CHOICES);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::MovedPermanently()` instead"
|
||||
)]
|
||||
pub const HttpMovedPermanently: StaticResponse =
|
||||
StaticResponse(StatusCode::MOVED_PERMANENTLY);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Found()` instead")]
|
||||
pub const HttpFound: StaticResponse = StaticResponse(StatusCode::FOUND);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::SeeOther()` instead")]
|
||||
pub const HttpSeeOther: StaticResponse = StaticResponse(StatusCode::SEE_OTHER);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::NotModified()` instead")]
|
||||
pub const HttpNotModified: StaticResponse = StaticResponse(StatusCode::NOT_MODIFIED);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::UseProxy()` instead")]
|
||||
pub const HttpUseProxy: StaticResponse = StaticResponse(StatusCode::USE_PROXY);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::TemporaryRedirect()` instead"
|
||||
)]
|
||||
pub const HttpTemporaryRedirect: StaticResponse =
|
||||
StaticResponse(StatusCode::TEMPORARY_REDIRECT);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::PermanentRedirect()` instead"
|
||||
)]
|
||||
pub const HttpPermanentRedirect: StaticResponse =
|
||||
StaticResponse(StatusCode::PERMANENT_REDIRECT);
|
||||
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::BadRequest()` instead")]
|
||||
pub const HttpBadRequest: StaticResponse = StaticResponse(StatusCode::BAD_REQUEST);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Unauthorized()` instead")]
|
||||
pub const HttpUnauthorized: StaticResponse = StaticResponse(StatusCode::UNAUTHORIZED);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::PaymentRequired()` instead"
|
||||
)]
|
||||
pub const HttpPaymentRequired: StaticResponse =
|
||||
StaticResponse(StatusCode::PAYMENT_REQUIRED);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Forbidden()` instead")]
|
||||
pub const HttpForbidden: StaticResponse = StaticResponse(StatusCode::FORBIDDEN);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::NotFound()` instead")]
|
||||
pub const HttpNotFound: StaticResponse = StaticResponse(StatusCode::NOT_FOUND);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::MethodNotAllowed()` instead"
|
||||
)]
|
||||
pub const HttpMethodNotAllowed: StaticResponse =
|
||||
StaticResponse(StatusCode::METHOD_NOT_ALLOWED);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::NotAcceptable()` instead"
|
||||
)]
|
||||
pub const HttpNotAcceptable: StaticResponse = StaticResponse(StatusCode::NOT_ACCEPTABLE);
|
||||
#[deprecated(
|
||||
since = "0.5.0",
|
||||
note = "please use `HttpResponse::ProxyAuthenticationRequired()` instead"
|
||||
)]
|
||||
pub const HttpProxyAuthenticationRequired: StaticResponse =
|
||||
StaticResponse(StatusCode::PROXY_AUTHENTICATION_REQUIRED);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::RequestTimeout()` instead"
|
||||
)]
|
||||
pub const HttpRequestTimeout: StaticResponse =
|
||||
StaticResponse(StatusCode::REQUEST_TIMEOUT);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Conflict()` instead")]
|
||||
pub const HttpConflict: StaticResponse = StaticResponse(StatusCode::CONFLICT);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::Gone()` instead")]
|
||||
pub const HttpGone: StaticResponse = StaticResponse(StatusCode::GONE);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::LengthRequired()` instead"
|
||||
)]
|
||||
pub const HttpLengthRequired: StaticResponse =
|
||||
StaticResponse(StatusCode::LENGTH_REQUIRED);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::PreconditionFailed()` instead"
|
||||
)]
|
||||
pub const HttpPreconditionFailed: StaticResponse =
|
||||
StaticResponse(StatusCode::PRECONDITION_FAILED);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::PayloadTooLarge()` instead"
|
||||
)]
|
||||
pub const HttpPayloadTooLarge: StaticResponse =
|
||||
StaticResponse(StatusCode::PAYLOAD_TOO_LARGE);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::UriTooLong()` instead")]
|
||||
pub const HttpUriTooLong: StaticResponse = StaticResponse(StatusCode::URI_TOO_LONG);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::UnsupportedMediaType()` instead"
|
||||
)]
|
||||
pub const HttpUnsupportedMediaType: StaticResponse =
|
||||
StaticResponse(StatusCode::UNSUPPORTED_MEDIA_TYPE);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::RangeNotSatisfiable()` instead"
|
||||
)]
|
||||
pub const HttpRangeNotSatisfiable: StaticResponse =
|
||||
StaticResponse(StatusCode::RANGE_NOT_SATISFIABLE);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::ExpectationFailed()` instead"
|
||||
)]
|
||||
pub const HttpExpectationFailed: StaticResponse =
|
||||
StaticResponse(StatusCode::EXPECTATION_FAILED);
|
||||
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::InternalServerError()` instead"
|
||||
)]
|
||||
pub const HttpInternalServerError: StaticResponse =
|
||||
StaticResponse(StatusCode::INTERNAL_SERVER_ERROR);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::NotImplemented()` instead"
|
||||
)]
|
||||
pub const HttpNotImplemented: StaticResponse =
|
||||
StaticResponse(StatusCode::NOT_IMPLEMENTED);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::BadGateway()` instead")]
|
||||
pub const HttpBadGateway: StaticResponse = StaticResponse(StatusCode::BAD_GATEWAY);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::ServiceUnavailable()` instead"
|
||||
)]
|
||||
pub const HttpServiceUnavailable: StaticResponse =
|
||||
StaticResponse(StatusCode::SERVICE_UNAVAILABLE);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::GatewayTimeout()` instead"
|
||||
)]
|
||||
pub const HttpGatewayTimeout: StaticResponse =
|
||||
StaticResponse(StatusCode::GATEWAY_TIMEOUT);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::VersionNotSupported()` instead"
|
||||
)]
|
||||
pub const HttpVersionNotSupported: StaticResponse =
|
||||
StaticResponse(StatusCode::HTTP_VERSION_NOT_SUPPORTED);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::VariantAlsoNegotiates()` instead"
|
||||
)]
|
||||
pub const HttpVariantAlsoNegotiates: StaticResponse =
|
||||
StaticResponse(StatusCode::VARIANT_ALSO_NEGOTIATES);
|
||||
#[deprecated(
|
||||
since = "0.5.0", note = "please use `HttpResponse::InsufficientStorage()` instead"
|
||||
)]
|
||||
pub const HttpInsufficientStorage: StaticResponse =
|
||||
StaticResponse(StatusCode::INSUFFICIENT_STORAGE);
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse::LoopDetected()` instead")]
|
||||
pub const HttpLoopDetected: StaticResponse = StaticResponse(StatusCode::LOOP_DETECTED);
|
||||
|
||||
#[deprecated(since = "0.5.0", note = "please use `HttpResponse` instead")]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct StaticResponse(StatusCode);
|
||||
|
||||
impl StaticResponse {
|
||||
pub fn build(&self) -> HttpResponseBuilder {
|
||||
HttpResponse::build(self.0)
|
||||
}
|
||||
pub fn build_from<S>(&self, req: &HttpRequest<S>) -> HttpResponseBuilder {
|
||||
req.build_response(self.0)
|
||||
}
|
||||
pub fn with_reason(self, reason: &'static str) -> HttpResponse {
|
||||
let mut resp = HttpResponse::new(self.0);
|
||||
resp.set_reason(reason);
|
||||
resp
|
||||
}
|
||||
pub fn with_body<B: Into<Body>>(self, body: B) -> HttpResponse {
|
||||
HttpResponse::with_body(self.0, body.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> Handler<S> for StaticResponse {
|
||||
type Result = HttpResponse;
|
||||
|
||||
fn handle(&mut self, _: HttpRequest<S>) -> HttpResponse {
|
||||
HttpResponse::new(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> RouteHandler<S> for StaticResponse {
|
||||
fn handle(&mut self, _: HttpRequest<S>) -> Reply {
|
||||
Reply::response(HttpResponse::new(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl Responder for StaticResponse {
|
||||
type Item = HttpResponse;
|
||||
type Error = Error;
|
||||
|
||||
fn respond_to(self, _: HttpRequest) -> Result<HttpResponse, Error> {
|
||||
Ok(self.build().finish())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StaticResponse> for HttpResponse {
|
||||
fn from(st: StaticResponse) -> Self {
|
||||
HttpResponse::new(st.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StaticResponse> for Reply {
|
||||
fn from(st: StaticResponse) -> Self {
|
||||
HttpResponse::new(st.0).into()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! STATIC_RESP {
|
||||
($name:ident, $status:expr) => {
|
||||
#[allow(non_snake_case)]
|
||||
@ -310,34 +81,13 @@ impl HttpResponse {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Body, HttpBadRequest, HttpOk, HttpResponse};
|
||||
use body::Body;
|
||||
use http::StatusCode;
|
||||
use httpresponse::HttpResponse;
|
||||
|
||||
#[test]
|
||||
fn test_build() {
|
||||
let resp = HttpOk.build().body(Body::Empty);
|
||||
let resp = HttpResponse::Ok().body(Body::Empty);
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_response() {
|
||||
let resp: HttpResponse = HttpOk.into();
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from() {
|
||||
let resp: HttpResponse = HttpOk.into();
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_with_reason() {
|
||||
let resp: HttpResponse = HttpOk.into();
|
||||
assert_eq!(resp.reason(), "OK");
|
||||
|
||||
let resp = HttpBadRequest.with_reason("test");
|
||||
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
|
||||
assert_eq!(resp.reason(), "test");
|
||||
}
|
||||
}
|
||||
|
@ -248,16 +248,6 @@ impl<S> HttpRequest<S> {
|
||||
self.as_ref().url.uri()
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deprecated(since = "0.5.3")]
|
||||
/// Returns mutable the Request Uri.
|
||||
///
|
||||
/// This might be useful for middlewares, e.g. path normalization.
|
||||
#[inline]
|
||||
pub fn uri_mut(&mut self) -> &mut Uri {
|
||||
self.as_mut().url.uri_mut()
|
||||
}
|
||||
|
||||
/// Read the Request method.
|
||||
#[inline]
|
||||
pub fn method(&self) -> &Method {
|
||||
@ -595,10 +585,7 @@ impl<S> fmt::Debug for HttpRequest<S> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#![allow(deprecated)]
|
||||
|
||||
use super::*;
|
||||
use http::{HttpTryFrom, Uri};
|
||||
use resource::ResourceHandler;
|
||||
use router::Resource;
|
||||
use server::ServerSettings;
|
||||
@ -611,14 +598,6 @@ mod tests {
|
||||
assert!(dbg.contains("HttpRequest"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_uri_mut() {
|
||||
let mut req = HttpRequest::default();
|
||||
assert_eq!(req.path(), "/");
|
||||
*req.uri_mut() = Uri::try_from("/test").unwrap();
|
||||
assert_eq!(req.path(), "/test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_no_request_cookies() {
|
||||
let req = HttpRequest::default();
|
||||
|
@ -138,6 +138,7 @@ mod extractor;
|
||||
mod handler;
|
||||
mod header;
|
||||
mod helpers;
|
||||
mod httpcodes;
|
||||
mod httpmessage;
|
||||
mod httprequest;
|
||||
mod httpresponse;
|
||||
@ -174,13 +175,6 @@ pub use httpresponse::HttpResponse;
|
||||
pub use json::Json;
|
||||
pub use scope::Scope;
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod httpcodes;
|
||||
|
||||
#[doc(hidden)]
|
||||
#[allow(deprecated)]
|
||||
pub use application::Application;
|
||||
|
||||
#[cfg(feature = "openssl")]
|
||||
pub(crate) const HAS_OPENSSL: bool = true;
|
||||
#[cfg(not(feature = "openssl"))]
|
||||
|
@ -19,14 +19,6 @@ pub use self::defaultheaders::DefaultHeaders;
|
||||
pub use self::errhandlers::ErrorHandlers;
|
||||
pub use self::logger::Logger;
|
||||
|
||||
#[cfg(feature = "session")]
|
||||
#[doc(hidden)]
|
||||
#[deprecated(
|
||||
since = "0.5.4", note = "please use `actix_web::middleware::session` instead"
|
||||
)]
|
||||
pub use self::session::{CookieSessionBackend, CookieSessionError, RequestSession,
|
||||
Session, SessionBackend, SessionImpl, SessionStorage};
|
||||
|
||||
/// Middleware start result
|
||||
pub enum Started {
|
||||
/// Execution completed
|
||||
|
@ -35,7 +35,7 @@
|
||||
//! # extern crate actix;
|
||||
//! # extern crate actix_web;
|
||||
//! use actix_web::{server, App, HttpRequest, Result};
|
||||
//! use actix_web::middleware::{RequestSession, SessionStorage, CookieSessionBackend};
|
||||
//! use actix_web::middleware::session::{RequestSession, SessionStorage, CookieSessionBackend};
|
||||
//!
|
||||
//! fn index(mut req: HttpRequest) -> Result<&'static str> {
|
||||
//! // access session data
|
||||
@ -86,7 +86,7 @@ use middleware::{Middleware, Response, Started};
|
||||
///
|
||||
/// ```rust
|
||||
/// use actix_web::*;
|
||||
/// use actix_web::middleware::RequestSession;
|
||||
/// use actix_web::middleware::session::RequestSession;
|
||||
///
|
||||
/// fn index(mut req: HttpRequest) -> Result<&'static str> {
|
||||
/// // access session data
|
||||
@ -123,7 +123,7 @@ impl<S> RequestSession for HttpRequest<S> {
|
||||
///
|
||||
/// ```rust
|
||||
/// use actix_web::*;
|
||||
/// use actix_web::middleware::RequestSession;
|
||||
/// use actix_web::middleware::session::RequestSession;
|
||||
///
|
||||
/// fn index(mut req: HttpRequest) -> Result<&'static str> {
|
||||
/// // access session data
|
||||
@ -179,7 +179,7 @@ unsafe impl Sync for SessionImplBox {}
|
||||
/// # extern crate actix;
|
||||
/// # extern crate actix_web;
|
||||
/// use actix_web::App;
|
||||
/// use actix_web::middleware::{SessionStorage, CookieSessionBackend};
|
||||
/// use actix_web::middleware::session::{SessionStorage, CookieSessionBackend};
|
||||
///
|
||||
/// fn main() {
|
||||
/// let app = App::new().middleware(
|
||||
@ -437,7 +437,7 @@ impl CookieSessionInner {
|
||||
///
|
||||
/// ```rust
|
||||
/// # extern crate actix_web;
|
||||
/// use actix_web::middleware::CookieSessionBackend;
|
||||
/// use actix_web::middleware::session::CookieSessionBackend;
|
||||
///
|
||||
/// # fn main() {
|
||||
/// let backend: CookieSessionBackend = CookieSessionBackend::signed(&[0; 32])
|
||||
|
@ -51,10 +51,6 @@ impl Url {
|
||||
&self.uri
|
||||
}
|
||||
|
||||
pub fn uri_mut(&mut self) -> &mut Uri {
|
||||
&mut self.uri
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &str {
|
||||
if let Some(ref s) = self.path {
|
||||
s
|
||||
|
Loading…
Reference in New Issue
Block a user