https://github.com/gowww/secure
🔑 Security utilities, CSP, HPKP, HSTS and other security wins
https://github.com/gowww/secure
csp go golang good-practices hpkp hsts http https policy secure security ssl
Last synced: about 1 month ago
JSON representation
🔑 Security utilities, CSP, HPKP, HSTS and other security wins
- Host: GitHub
- URL: https://github.com/gowww/secure
- Owner: gowww
- License: mit
- Created: 2017-07-02T20:03:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-15T14:27:33.000Z (over 5 years ago)
- Last Synced: 2025-03-31T09:18:53.039Z (about 1 year ago)
- Topics: csp, go, golang, good-practices, hpkp, hsts, http, https, policy, secure, security, ssl
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [](https://github.com/gowww) secure [](https://godoc.org/github.com/gowww/secure) [](https://travis-ci.org/gowww/secure) [](https://coveralls.io/github/gowww/secure?branch=master) [](https://goreportcard.com/report/github.com/gowww/secure) 
Package [secure](https://godoc.org/github.com/gowww/secure) provides security utilities, CSP, HPKP, HSTS and other security wins.
## Installing
1. Get package:
```Shell
go get -u github.com/gowww/secure
```
2. Import it in your code:
```Go
import "github.com/gowww/secure"
```
## Usage
To wrap an [http.Handler](https://golang.org/pkg/net/http/#Handler), use [Handle](https://godoc.org/github.com/gowww/secure#Handle):
```Go
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello")
})
http.ListenAndServe(":8080", secure.Handle(mux, nil))
```
To wrap an [http.HandlerFunc](https://golang.org/pkg/net/http/#HandlerFunc), use [HandleFunc](https://godoc.org/github.com/gowww/secure#HandleFunc):
```Go
http.Handle("/", secure.HandleFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello")
}, nil))
http.ListenAndServe(":8080", nil)
```
To set custom security options, see [Options](https://godoc.org/github.com/gowww/secure#Options) GoDoc reference.