Secure is an HTTP middleware for Go that facilitates some quick security wins. It's a standard net/http Handler, and can be used with many frameworks or directly with Go's net/http package. Be sure to include the Secure middleware as close to the top (beginning) as possible (but after logging and recovery). It's best to do the allowed hosts and SSL check before anything else. When IsDevelopment is true, the AllowedHosts, SSLRedirect, STS header, and HPKP header will not be in effect. This allows you to work in development/test mode and not have any annoying redirects to HTTPS (ie. development can happen on HTTP), or block localhost has a bad host. Secure comes with a variety of configuration options. Secure allows you to set a custom function for the AllowRequestFunc option. You can use this function as a custom filter to allow the request to continue or simply reject it.
Features
- Facilitates some quick security wins
- It's a standard net/http Handler
- Can be used with many frameworks or directly with Go's net/http package
- Secure comes with a variety of configuration options
- Set the IsDevelopment option to true when developing
- Allow Request Function
- Redirect HTTP to HTTPS