mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 05:41:12 +00:00
moved standard http headers
This commit is contained in:
parent
412ef6f7ae
commit
062e275388
2 changed files with 7 additions and 6 deletions
|
@ -28,12 +28,6 @@ type internalServerError struct{ error }
|
||||||
// If the error is of another type, it is considered as an internal error and its message is logged.
|
// If the error is of another type, it is considered as an internal error and its message is logged.
|
||||||
func errorHandler(f func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc {
|
func errorHandler(f func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
// standard header variables that should be set, for good measure.
|
|
||||||
w.Header().Add("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate")
|
|
||||||
w.Header().Add("X-Frame-Options", "DENY")
|
|
||||||
w.Header().Add("X-Content-Type-Options", "nosniff")
|
|
||||||
w.Header().Add("X-XSS-Protection", "1; mode=block")
|
|
||||||
|
|
||||||
// serve the request
|
// serve the request
|
||||||
err := f(w, r)
|
err := f(w, r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -122,11 +122,18 @@ func main() {
|
||||||
strings.HasPrefix(r.URL.Path, "/scripts/"),
|
strings.HasPrefix(r.URL.Path, "/scripts/"),
|
||||||
strings.HasPrefix(r.URL.Path, "/styles/"),
|
strings.HasPrefix(r.URL.Path, "/styles/"),
|
||||||
strings.HasPrefix(r.URL.Path, "/views/"):
|
strings.HasPrefix(r.URL.Path, "/views/"):
|
||||||
|
// serve static conent
|
||||||
fserver.ServeHTTP(w, r)
|
fserver.ServeHTTP(w, r)
|
||||||
case strings.HasPrefix(r.URL.Path, "/logout"),
|
case strings.HasPrefix(r.URL.Path, "/logout"),
|
||||||
strings.HasPrefix(r.URL.Path, "/login/"),
|
strings.HasPrefix(r.URL.Path, "/login/"),
|
||||||
strings.HasPrefix(r.URL.Path, "/v1/"),
|
strings.HasPrefix(r.URL.Path, "/v1/"),
|
||||||
strings.HasPrefix(r.URL.Path, "/ws/"):
|
strings.HasPrefix(r.URL.Path, "/ws/"):
|
||||||
|
// standard header variables that should be set, for good measure.
|
||||||
|
w.Header().Add("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate")
|
||||||
|
w.Header().Add("X-Frame-Options", "DENY")
|
||||||
|
w.Header().Add("X-Content-Type-Options", "nosniff")
|
||||||
|
w.Header().Add("X-XSS-Protection", "1; mode=block")
|
||||||
|
// serve dynamic content
|
||||||
router.ServeHTTP(w, r)
|
router.ServeHTTP(w, r)
|
||||||
default:
|
default:
|
||||||
w.Write(index)
|
w.Write(index)
|
||||||
|
|
Loading…
Reference in a new issue