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 {
217217 }
218218 s := http.Server {
219219 Addr : ":443" ,
220- Handler : serveHandler (),
220+ Handler : HSTS ( serveHandler () ),
221221 TLSConfig : & tls.Config {
222222 GetCertificate : localClient .GetCertificate ,
223223 },
@@ -357,6 +357,15 @@ func redirectHandler(hostname string) http.Handler {
357357 })
358358}
359359
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+
360369// serverHandler returns the main http.Handler for serving all requests.
361370func serveHandler () http.Handler {
362371 mux := http .NewServeMux ()
You can’t perform that action at this time.
0 commit comments