项目作者: acoshift

项目描述 :
HSTS Middleware
高级语言: Go
项目地址: git://github.com/acoshift/hsts.git
创建时间: 2017-08-05T01:44:54Z
项目社区:https://github.com/acoshift/hsts

开源协议:MIT License

下载


hsts

Go Report Card
GoDoc

HSTS middleware for Golang net/http

Example

  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. "time"
  6. "github.com/acoshift/hsts"
  7. "github.com/acoshift/middleware"
  8. )
  9. func handler(w http.ResponseWriter, r *http.Request) {
  10. fmt.Fprintf(w, "OK")
  11. }
  12. func main() {
  13. h := middleware.Chain(
  14. hsts.New(hsts.Config{
  15. Skipper: middleware.SkipHTTP,
  16. MaxAge: 31536000 * time.Second,
  17. IncludeSubDomains: true,
  18. Preload: true,
  19. }),
  20. )(http.HandlerFunc(handler))
  21. http.ListenAndServe(":8080", h)
  22. }