File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ func Run() error {
217
217
}
218
218
s := http.Server {
219
219
Addr : ":443" ,
220
- Handler : serveHandler (),
220
+ Handler : HSTS ( serveHandler () ),
221
221
TLSConfig : & tls.Config {
222
222
GetCertificate : localClient .GetCertificate ,
223
223
},
@@ -357,6 +357,15 @@ func redirectHandler(hostname string) http.Handler {
357
357
})
358
358
}
359
359
360
+ // HSTS wraps the provided handler and sets Strict-Transport-Security header on
361
+ // all responses.
362
+ func HSTS (h http.Handler ) http.Handler {
363
+ return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
364
+ w .Header ().Set ("Strict-Transport-Security" , "max-age=31536000" )
365
+ h .ServeHTTP (w , r )
366
+ })
367
+ }
368
+
360
369
// serverHandler returns the main http.Handler for serving all requests.
361
370
func serveHandler () http.Handler {
362
371
mux := http .NewServeMux ()
You can’t perform that action at this time.
0 commit comments