// HSTS creates new HSTS middleware
550241
func HSTS(config HSTSConfig) Middleware {
	if config.Skipper == nil {
		config.Skipper = DefaultSkipper
	}

	hs := "max-age=" + strconv.FormatInt(int64(config.MaxAge/time.Second), 10)
	if config.IncludeSubDomains {
		hs += "; includeSubDomains"
	}
	if config.Preload {
		hs += "; preload"
	}

	return func(h http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
			if config.Skipper(r) {
				h.ServeHTTP(w, r)
				return
			}
			w.Header().Set("Strict-Transport-Security", hs)
			h.ServeHTTP(w, r)
		})
	}
}
1274121
func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {
	dht, err := New(ctx, h, opts.Datastore(dstore))
	if err != nil {
		panic(err)
	}
	return dht
}
1034571
func (s *TestInvokeAuthorizerInput) SetHeaders(v map[string]*string) *TestInvokeAuthorizerInput {
	s.Headers = v
	return s
}
585876
func (s *SearchOutput) SetHits(v *Hits) *SearchOutput {
	s.Hits = v
	return s
}
169343
func newTHS(s BaseSentence) (THS, error) {
	p := newParser(s)
	p.AssertType(TypeTHS)
	m := THS{
		BaseSentence: s,
		Heading:      p.Float64(0, "heading"),
		Status:       p.EnumString(1, "status", AutonomousTHS, EstimatedTHS, ManualTHS, SimulatorTHS, InvalidTHS),
	}
	return m, p.Err()
}
674755
func (ref *Config) SetTLS(tlsConfig *tls.Config) (err error) {
	ref.Net.TLS.Enable = true
	ref.Net.TLS.Config = tlsConfig

	return nil
}
953465
func (s *ServeMux) MiddlewareHost(host, path string, middleware Middleware) {
	s.RouteHost(host, path).Middleware(middleware)
}
118023
func Ls(c *cli.Context) {
	hostsfile := AlwaysLoadHostFile(c)
	maxdomain := 0
	maxip := 0
	for _, hostname := range hostsfile.Hosts {
		dlen := len(hostname.Domain)
		if dlen > maxdomain {
			maxdomain = dlen
		}
		ilen := len(hostname.IP)
		if ilen > maxip {
			maxip = ilen
		}
	}

	for _, hostname := range hostsfile.Hosts {
		fmt.Printf("%s -> %s %s\n",
			StrPadRight(hostname.Domain, maxdomain),
			StrPadRight(hostname.IP.String(), maxip),
			hostname.FormatEnabled())
	}
}
16693
func (m *Miniredis) HSet(k, f, v string) {
	m.DB(m.selectedDB).HSet(k, f, v)
}
744435
func (wc *WebhookContext) Headers() map[string][]string {
	return map[string][]string(wc.gin.Request.Header)
}
1040018
func (r *route) Middlewares(
	middlewares ...types.Middleware) types.Route {
	r.middlewares = append(r.middlewares, middlewares...)
	return r
}
1069113
func (c *syncClient) Hset(arg0 string, arg1 string, arg2 []byte) (err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(arg1)
	arg2bytes := arg2

	_, err = c.conn.ServiceRequest(&HSET, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	return
}
1213258
func RunTLS(addr string, config *tls.Config) {
	mainServer.RunTLS(addr, config)
}
178194
func (m Metadata) Headers(metaPrefix string) Headers {
	h := Headers{}
	for key, value := range m {
		key = http.CanonicalHeaderKey(metaPrefix + key)
		h[key] = value
	}
	return h
}
1111188
func LunchTLS(addr string, conf *tls.Config, handle http.Handler) error {
	_, _, err := CreateTLS(addr, conf, handle)
	return err
}
1010741
func MiddlewareHeaders(vs map[string]string) Middleware {
	return func(h http.Handler) http.Handler {
		return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
			// Add headers
			handleHeaders(vs, rw)

			// Next handler
			h.ServeHTTP(rw, r)
		})
	}
}
933211
func (ctx *Context) ToTLS() {
	u := ctx.URI()
	u.SetScheme(https)
	ctx.Redirect(u.String(), redirectCode)
}