pub struct RedirectHTTPS { /* private fields */ }
Expand description
Middleware for actix-web
which redirects all http
requests to https
with optional url
string replacements.
§Usage
use actix_web::{App, web, HttpResponse};
use actix_web_middleware_redirect_https::RedirectHTTPS;
App::new()
.wrap(RedirectHTTPS::default())
.route("/", web::get().to(|| HttpResponse::Ok()
.content_type("text/plain")
.body("Always HTTPS!")));
Implementations§
Source§impl RedirectHTTPS
impl RedirectHTTPS
Sourcepub fn with_replacements(replacements: &[(String, String)]) -> Self
pub fn with_replacements(replacements: &[(String, String)]) -> Self
Creates a RedirectHTTPS middleware which also performs string replacement on the final url. This is useful when not running on the default web and ssl ports (80 and 443) since we will need to change the development web port in the hostname to the development ssl port.
§Usage
use actix_web::{App, web, HttpResponse};
use actix_web_middleware_redirect_https::RedirectHTTPS;
App::new()
.wrap(RedirectHTTPS::with_replacements(&[(":8080".to_owned(), ":8443".to_owned())]))
.route("/", web::get().to(|| HttpResponse::Ok()
.content_type("text/plain")
.body("Always HTTPS on non-default ports!")));
Trait Implementations§
Source§impl Clone for RedirectHTTPS
impl Clone for RedirectHTTPS
Source§fn clone(&self) -> RedirectHTTPS
fn clone(&self) -> RedirectHTTPS
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for RedirectHTTPS
impl Default for RedirectHTTPS
Source§fn default() -> RedirectHTTPS
fn default() -> RedirectHTTPS
Returns the “default value” for a type. Read more
Source§impl<S, B> Transform<S> for RedirectHTTPSwhere
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
impl<S, B> Transform<S> for RedirectHTTPSwhere
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
Source§type Request = ServiceRequest
type Request = ServiceRequest
Requests handled by the service.
Source§type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses given by the service.
Source§type Transform = RedirectHTTPSService<S>
type Transform = RedirectHTTPSService<S>
The
TransformService
value created by this factorySource§type Future = Ready<Result<<RedirectHTTPS as Transform<S>>::Transform, <RedirectHTTPS as Transform<S>>::InitError>>
type Future = Ready<Result<<RedirectHTTPS as Transform<S>>::Transform, <RedirectHTTPS as Transform<S>>::InitError>>
The future response value.
Source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Creates and returns a new Transform component, asynchronously
Source§fn map_init_err<F, E>(self, f: F) -> TransformMapInitErr<Self, S, F, E>
fn map_init_err<F, E>(self, f: F) -> TransformMapInitErr<Self, S, F, E>
Map this transforms’s factory error to a different error,
returning a new transform service factory.
Auto Trait Implementations§
impl Freeze for RedirectHTTPS
impl RefUnwindSafe for RedirectHTTPS
impl Send for RedirectHTTPS
impl Sync for RedirectHTTPS
impl Unpin for RedirectHTTPS
impl UnwindSafe for RedirectHTTPS
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more