gowww / secure

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

License:MIT License


Languages

Language:Go 100.0%