pub struct RedirectHttps { /* private fields */ }Expand description
Configuration for the HTTP-to-HTTPS redirect middleware.
Build with RedirectHttps::new() and chain methods to adjust the redirect
status code or target HTTPS port, then pass to RedirectHttpsLayer::new().
§Examples
use http::StatusCode;
use rune_axum_redirect_https::RedirectHttps;
// HTTP on :8080 → HTTPS on :8443, 301 for legacy compatibility
let config = RedirectHttps::new()
.status(StatusCode::MOVED_PERMANENTLY)
.https_port(8443);Implementations§
Source§impl RedirectHttps
impl RedirectHttps
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a RedirectHttps with defaults: 308 Permanent Redirect, standard HTTPS port.
Sourcepub fn status(self, status: StatusCode) -> Self
pub fn status(self, status: StatusCode) -> Self
Sets the redirect status code.
Defaults to 308 Permanent Redirect, which preserves the HTTP method.
Use 301 Moved Permanently when you need compatibility with older
clients that do not support 308.
[!WARNING]
301converts POST to GET in many browsers and HTTP clients. Prefer308unless you have a specific reason to use301.
Sourcepub fn https_port(self, port: u16) -> Self
pub fn https_port(self, port: u16) -> Self
Sets the HTTPS port in the redirect Location URL.
When set, any port in the Host header is stripped and replaced with
this value. Useful when HTTP and HTTPS run on non-standard ports (e.g.
8080 → 8443). When unset the port is omitted from the URL, which
directs clients to the standard HTTPS port (443).
Trait Implementations§
Source§impl Clone for RedirectHttps
impl Clone for RedirectHttps
Source§fn clone(&self) -> RedirectHttps
fn clone(&self) -> RedirectHttps
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more