2018-04-28 07:25:00 +02:00
|
|
|
// Copyright 2018 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2018-08-25 06:51:50 +02:00
|
|
|
package middleware // import "miniflux.app/middleware"
|
2018-04-28 07:25:00 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// HeaderConfig changes config values according to HTTP headers.
|
|
|
|
func (m *Middleware) HeaderConfig(next http.Handler) http.Handler {
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if r.Header.Get("X-Forwarded-Proto") == "https" {
|
|
|
|
m.cfg.IsHTTPS = true
|
|
|
|
}
|
2018-10-08 03:42:43 +02:00
|
|
|
|
|
|
|
if m.cfg.IsHTTPS && m.cfg.HasHSTS() {
|
|
|
|
w.Header().Set("Strict-Transport-Security", "max-age=31536000")
|
|
|
|
}
|
|
|
|
|
2018-04-28 07:25:00 +02:00
|
|
|
next.ServeHTTP(w, r)
|
|
|
|
})
|
|
|
|
}
|