Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acoshift/hsts
HSTS Middleware
https://github.com/acoshift/hsts
golang hsts http middleware
Last synced: about 2 months ago
JSON representation
HSTS Middleware
- Host: GitHub
- URL: https://github.com/acoshift/hsts
- Owner: acoshift
- License: mit
- Created: 2017-08-05T01:44:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-06T16:17:30.000Z (over 7 years ago)
- Last Synced: 2024-06-20T03:55:01.505Z (7 months ago)
- Topics: golang, hsts, http, middleware
- Language: Go
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hsts
[![Go Report Card](https://goreportcard.com/badge/github.com/acoshift/hsts)](https://goreportcard.com/report/github.com/acoshift/hsts)
[![GoDoc](https://godoc.org/github.com/acoshift/hsts?status.svg)](https://godoc.org/github.com/acoshift/hsts)HSTS middleware for Golang net/http
### Example
```go
package mainimport (
"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)
}
```