Skip to main content

http_to_https_router

Function http_to_https_router 

Source
pub fn http_to_https_router(https_port: u16) -> Router
Expand description

Builds a router whose fallback redirects every request to the https:// equivalent on the same host, suitable for binding to port 80 alongside the real TLS listener on https_port.

The Host header is parsed as an RFC 3986 authority before being placed in the Location; malformed values (including CRLF or scheme smuggling) produce a 400 Bad Request to prevent open-redirect / cache-poisoning phishing. For strict deployments, prefer http_to_https_router_with_allowed_hosts.

ยงExamples

use tako::redirect::http_to_https_router;

// serve(http80_listener, http_to_https_router(443)).await;