hsts

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redirect

func Redirect() xun.Middleware

Redirect is a middleware that redirects plain HTTP requests to HTTPS.

func WriteHeader

func WriteHeader(opts ...Option) xun.Middleware

WriteHeader is a middleware that sets the STS response header for a HTTPs request.

Types

type Config

type Config struct {
	MaxAge            int64 // MaxAge specifies the duration for which the HSTS policy is in effect.
	IncludeSubDomains bool  // IncludeSubDomains indicates whether the HSTS policy applies to subdomains.
	Preload           bool  // Preload indicates whether the domain should be preloaded into browsers' HSTS lists.
}

Config represents the configuration options for HSTS (HTTP Strict Transport Security). It includes various settings such as MaxAge, IncludeSubDomains, and Preload.

type Option

type Option func(c *Config)

Option is a function that modifies a Config instance. It is used to configure HSTS settings by applying various options.

func WithIncludeSubDomains

func WithIncludeSubDomains() Option

WithIncludeSubDomains sets the HSTS policy applies to subdomains.

func WithMaxAge

func WithMaxAge(t time.Duration) Option

WithMaxAge sets the maximum age for the HSTS policy.

The maximum age specifies the duration for which the HSTS policy is in effect. Note that the maximum age is specified in seconds, so "1h" would be equivalent to 3600.

func WithPreload

func WithPreload() Option

WithPreload sets the domain should be preloaded into browsers' HSTS lists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL