rune-axum-redirect-https 0.1.1

Redirect HTTP requests to HTTPS — Tower middleware for Axum
Documentation
//! HTTP-to-HTTPS redirect middleware for Axum and Tower.
//!
//! A [`tower::Layer`] that detects incoming HTTP requests and issues a
//! permanent redirect to the HTTPS equivalent. HTTPS requests are forwarded
//! to the inner service unchanged.
//!
//! Detection follows this priority order:
//!
//! 1. `X-Forwarded-Proto: http` — set by most reverse proxies when the
//!    upstream connection is plain HTTP.
//! 2. URI scheme of `http` — present in direct (non-proxy) connections.
//!
//! If neither indicator is present the request passes through unchanged,
//! which is the safe default when the protocol cannot be determined.
//!
//! # Features
//!
//! - Configurable redirect status: `308 Permanent Redirect` (default,
//!   method-preserving) or `301 Moved Permanently` (legacy compatibility).
//! - Optional HTTPS port override for non-standard port setups.
//! - Graceful fallback: if no `Host` header is present the request is
//!   forwarded rather than returning a malformed redirect without `Location`.
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use axum::{routing::get, Router};
//! use rune_axum_redirect_https::RedirectHttpsLayer;
//!
//! let app: Router = Router::new()
//!     .route("/", get(|| async { "hello" }))
//!     .layer(RedirectHttpsLayer::default());
//! ```
//!
//! # Custom Configuration
//!
//! ```rust,no_run
//! use axum::{routing::get, Router};
//! use http::StatusCode;
//! use rune_axum_redirect_https::{RedirectHttps, RedirectHttpsLayer};
//!
//! // HTTP on :8080 → HTTPS on :8443, using 301 for legacy clients
//! let layer = RedirectHttpsLayer::new(
//!     RedirectHttps::new()
//!         .status(StatusCode::MOVED_PERMANENTLY)
//!         .https_port(8443),
//! );
//!
//! let app: Router = Router::new()
//!     .route("/", get(|| async { "hello" }))
//!     .layer(layer);
//! ```

pub use layer::{RedirectHttps, RedirectHttpsLayer};

mod layer;