Struct actix_web_lab::middleware::RedirectHttps
source · pub struct RedirectHttps { /* private fields */ }
Expand description
A middleware to redirect traffic to HTTPS if connection is insecure.
§HSTS
HTTP Strict Transport Security (HSTS) is configurable. Care should be taken when setting up HSTS for your site; misconfiguration can potentially leave parts of your site in an unusable state. By default it is disabled.
See StrictTransportSecurity
docs for more info.
§Examples
use actix_web_lab::{header::StrictTransportSecurity, middleware::RedirectHttps};
let mw = RedirectHttps::default();
let mw = RedirectHttps::default().to_port(8443);
let mw = RedirectHttps::with_hsts(StrictTransportSecurity::default());
let mw = RedirectHttps::with_hsts(StrictTransportSecurity::new(Duration::from_secs(60 * 60)));
let mw = RedirectHttps::with_hsts(StrictTransportSecurity::recommended());
App::new().wrap(mw)
Implementations§
source§impl RedirectHttps
impl RedirectHttps
sourcepub fn with_hsts(hsts: StrictTransportSecurity) -> Self
pub fn with_hsts(hsts: StrictTransportSecurity) -> Self
Construct new HTTP redirect middleware with strict transport security configuration.
Trait Implementations§
source§impl Clone for RedirectHttps
impl Clone for RedirectHttps
source§fn clone(&self) -> RedirectHttps
fn clone(&self) -> RedirectHttps
Returns a copy 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 Debug for RedirectHttps
impl Debug for RedirectHttps
source§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, ServiceRequest> for RedirectHttps
impl<S, B> Transform<S, ServiceRequest> for RedirectHttps
source§type Response = ServiceResponse<EitherBody<B, ()>>
type Response = ServiceResponse<EitherBody<B, ()>>
Responses produced by the service.
source§type Transform = RedirectHttpsMiddleware<S>
type Transform = RedirectHttpsMiddleware<S>
The
TransformService
value created by this factorysource§type Future = Ready<Result<<RedirectHttps as Transform<S, ServiceRequest>>::Transform, <RedirectHttps as Transform<S, ServiceRequest>>::InitError>>
type Future = Ready<Result<<RedirectHttps as Transform<S, ServiceRequest>>::Transform, <RedirectHttps as Transform<S, ServiceRequest>>::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
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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