Package hsts provides access to the Chromium HSTS preloaded list.
The list is manually converted into go code occasionally with go generate
.
To request your site be added to the list, please visit hstspreload.org.
import "go.tmthrgd.dev/hsts"
Hostnames (or domain names) can be checked for inclusion in the list by calling
IsPreloaded
:
if hsts.IsPreloaded(hostname) {
// ...
}
Transport
is a
http.RoundTripper
that
automatically upgrades insecure http requests to hosts in the preload list into
secure https requests. It can be used by setting the (*http.Client).Transport
field as follows:
client := &http.Client{
Transport: &hsts.Transport{},
}
resp, err := client.Do(req)
The minimal perfect hashing code was taken from cespare/mph by Caleb Spare and is licensed under an MIT License.