header::STRICT_TRANSPORT_SECURITY,
HeaderValue::from_static("max-age=31536000; includeSubDomains; preload"),
))
.layer(
CorsLayer::new()
.allow_methods([http::Method::GET])
.allow_origin(Any),
)
.layer(CompressionLayer::new())
.with_state(server_config);
match (self.http_port(), self.https_port()) {
(Some(http_port), None) => {
self
.spawn(router, handle, http_port, SpawnConfig::Http)?
.await??
}
(None, Some(https_port)) => {
self
.spawn(
router,
handle,
https_port,
SpawnConfig::Https(self.acceptor(&options)?),
)?
.await??
}
(Some(http_port), Some(https_port)) => {
let http_spawn_config = if self.redirect_http_to_https {
SpawnConfig::Redirect(if https_port == 443 {
format!("https://{}", acme_domains[0])