Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" "net/http" "github.com/tam7t/hsts" ) func main() { hosts := hsts.NewMemStorage() tr := &hsts.Transport{ Transport: http.DefaultTransport, Storage: hosts, } client := &http.Client{Transport: tr} // http://github.com will redirect to https, then set hsts header fmt.Println("GET: http://github.com") _, err := client.Get("http://github.com") if err != nil { fmt.Println(err) } // subsequent request to http://github.com will be intercepted and forced over // https fmt.Println("GET: http://github.com") _, err = client.Get("http://github.com") if err != nil { fmt.Println(err) } }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemStorage ¶
type MemStorage struct {
// contains filtered or unexported fields
}
MemStorage is threadsafe hsts host storage backed by an in-memory map
func NewMemStorage ¶
func NewMemStorage() *MemStorage
NewMemStorage initializes hsts in-memory datastructure
func (*MemStorage) Contains ¶
func (hs *MemStorage) Contains(h string) bool
Contains whether storage has host
type Transport ¶
type Transport struct { Transport http.RoundTripper Storage Storage }
Transport contains the hosts that must be https
Click to show internal directories.
Click to hide internal directories.