comparison pkg/middleware/nosniff.go @ 5283:fdbc28a71691

Made setting of No Sniff headers for served files a reusable middleware.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 28 Jun 2020 02:54:58 +0200
parents
children 1222b777f51f
comparison
equal deleted inserted replaced
5282:12e2422ae57c 5283:fdbc28a71691
1 // This is Free Software under GNU Affero General Public License v >= 3.0
2 // without warranty, see README.md and license for details.
3 //
4 // SPDX-License-Identifier: AGPL-3.0-or-later
5 // License-Filename: LICENSES/AGPL-3.0.txt
6 //
7 // Copyright (C) 2020 by via donau
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
9 // Software engineering by Intevation GmbH
10 //
11 // Author(s):
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
13
14 package middleware
15
16 import "net/http"
17
18 func NoSniff(next http.Handler) http.Handler {
19 return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
20 res.Header().Set("X-Frame-Options", "sameorigin")
21 res.Header().Set("X-Content-Type-Options", "nosniff")
22 next.ServeHTTP(res, req)
23 })
24 }