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};
App::new().wrap(RedirectHttps::default());
App::new().wrap(RedirectHttps::default().to_port(8443));
App::new().wrap(RedirectHttps::with_hsts(StrictTransportSecurity::default()));
App::new().wrap(RedirectHttps::with_hsts(StrictTransportSecurity::new(Duration::from_secs(60 * 60))));
App::new().wrap(RedirectHttps::with_hsts(StrictTransportSecurity::recommended()));
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 RedirectHttpswhere
S: Service<ServiceRequest, Response = ServiceResponse<B>> + 'static,
impl<S, B> Transform<S, ServiceRequest> for RedirectHttpswhere S: Service<ServiceRequest, Response = ServiceResponse<B>> + 'static,
§type Response = ServiceResponse<EitherBody<B, ()>>
type Response = ServiceResponse<EitherBody<B, ()>>
Responses produced by the service.
§type Error = <S as Service<ServiceRequest>>::Error
type Error = <S as Service<ServiceRequest>>::Error
Errors produced by the service.
§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 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