Skip to content
/ secure Public

๐Ÿ”‘ Security utilities, CSP, HPKP, HSTS and other security wins

License

Notifications You must be signed in to change notification settings

gowww/secure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

gowww secure GoDoc Build Coverage Go Report Status Testing

Package secure provides security utilities, CSP, HPKP, HSTS and other security wins.

Installing

  1. Get package:

    go get -u github.com/gowww/secure
  2. Import it in your code:

    import "github.com/gowww/secure"

Usage

To wrap an http.Handler, use Handle:

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, use HandleFunc:

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 GoDoc reference.