HSTS Middleware
HSTS middleware for Golang net/http
package main
import (
"fmt"
"net/http"
"time"
"github.com/acoshift/hsts"
"github.com/acoshift/middleware"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "OK")
}
func main() {
h := middleware.Chain(
hsts.New(hsts.Config{
Skipper: middleware.SkipHTTP,
MaxAge: 31536000 * time.Second,
IncludeSubDomains: true,
Preload: true,
}),
)(http.HandlerFunc(handler))
http.ListenAndServe(":8080", h)
}