Documentation
¶
Index ¶
- func WrapHandler(handler http.Handler, opts MiddlewareOptions) http.Handler
- type MiddlewareOptions
- type Mode
- type Server
- type TLSAutoEncryptConfig
- type TLSEncryptOption
- type TLSExternalConfig
- type TLSRemoteAPIConfig
- type TLSRemoteAPIOption
- type TLSRemoteAPIResponse
- type TLSSelfSignedConfig
- type TLSSelfSignedOption
- type TLSer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WrapHandler ¶
func WrapHandler(handler http.Handler, opts MiddlewareOptions) http.Handler
Wrap decorates the provided handler with the optional middleware configured in opts.
Types ¶
type MiddlewareOptions ¶
type MiddlewareOptions struct {
AddRequestStartHeader bool
GzipEnabled bool
GzipJitter int // Maximum gzip padding in bytes; zero disables padding.
GzipDisableOnAuth bool
AddRequestID bool
TrustRequestIDHeader bool
LogRequests bool
MaxRequestBodyBytes int
}
Options configures the optional HTTP middleware that can wrap the Gin engine.
type Mode ¶
type Mode string
Mode defines the server's running mode.
const ( // ModeTLSSelfSigned runs the server using a self-signed TLS certificate (localhost or testing use). ModeTLSSelfSigned Mode = "self-signed" // ModeTLSEncrypt runs the server using a Let's Encrypt certificate (automatic certificate management). ModeTLSEncrypt Mode = "encrypt" // ModeTLSExternal runs the server using user-provided TLS certificate and key files. ModeTLSExternal Mode = "external" // ModeRemoteAPI runs the server using remote API to manage TLS certificate. ModeRemoteAPI = "remote-api" )
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server TLS server.
type TLSAutoEncryptConfig ¶
type TLSAutoEncryptConfig struct {
// contains filtered or unexported fields
}
func NewTLSEAutoEncryptConfig ¶
func NewTLSEAutoEncryptConfig(domain string, email string, opts ...TLSEncryptOption) *TLSAutoEncryptConfig
func (*TLSAutoEncryptConfig) Validate ¶
func (c *TLSAutoEncryptConfig) Validate() error
type TLSEncryptOption ¶
type TLSEncryptOption func(*tlsEncryptOptions)
TLSEncryptOption set tlsEncryptOptions.
func WithTLSEncryptCacheDir ¶
func WithTLSEncryptCacheDir(cacheDir string) TLSEncryptOption
WithTLSEncryptCacheDir sets the directory to store Let's Encrypt certificates.
func WithTLSEncryptDomains ¶
func WithTLSEncryptDomains(domains ...string) TLSEncryptOption
WithTLSEncryptDomains adds domains to the Let's Encrypt host whitelist.
func WithTLSEncryptEnableRedirect ¶
func WithTLSEncryptEnableRedirect(httpAddr ...string) TLSEncryptOption
WithTLSEncryptEnableRedirect enables the HTTP-to-HTTPS redirect service. By default, it listens on ":80". An optional httpAddr can be provided to specify a different address.
func WithTLSEncryptRedirectHTTPSPort ¶
func WithTLSEncryptRedirectHTTPSPort(httpsPort int) TLSEncryptOption
WithTLSEncryptRedirectHTTPSPort sets the HTTPS port used in HTTP-to-HTTPS redirects. When httpsPort is 443 or less than 1, redirects use the default HTTPS port without appending a port to the target host.
type TLSExternalConfig ¶
type TLSExternalConfig struct {
// contains filtered or unexported fields
}
func NewTLSExternalConfig ¶
func NewTLSExternalConfig(certFile, keyFile string) *TLSExternalConfig
func (*TLSExternalConfig) Validate ¶
func (c *TLSExternalConfig) Validate() error
type TLSRemoteAPIConfig ¶
type TLSRemoteAPIConfig struct {
// contains filtered or unexported fields
}
TLSRemoteAPIConfig implements certificate retrieval from other service API
func NewTLSRemoteAPIConfig ¶
func NewTLSRemoteAPIConfig(url string, opts ...TLSRemoteAPIOption) *TLSRemoteAPIConfig
func (*TLSRemoteAPIConfig) Validate ¶
func (c *TLSRemoteAPIConfig) Validate() error
type TLSRemoteAPIOption ¶
type TLSRemoteAPIOption func(*tlsRemoteAPIOptions)
TLSRemoteAPIOption set tlsRemoteAPIOptions.
func WithTLSRemoteAPICacheDir ¶
func WithTLSRemoteAPICacheDir(cacheDir string) TLSRemoteAPIOption
WithTLSRemoteAPICacheDir set cacheDir for tlsRemoteAPI.
func WithTLSRemoteAPIHeaders ¶
func WithTLSRemoteAPIHeaders(headers map[string]string) TLSRemoteAPIOption
WithTLSRemoteAPIHeaders set headers for tlsRemoteAPI.
func WithTLSRemoteAPITimeout ¶
func WithTLSRemoteAPITimeout(timeout time.Duration) TLSRemoteAPIOption
WithTLSRemoteAPITimeout set timeout for tlsRemoteAPI.
type TLSRemoteAPIResponse ¶
type TLSSelfSignedConfig ¶
type TLSSelfSignedConfig struct {
// contains filtered or unexported fields
}
func NewTLSSelfSignedConfig ¶
func NewTLSSelfSignedConfig(opts ...TLSSelfSignedOption) *TLSSelfSignedConfig
func (*TLSSelfSignedConfig) Validate ¶
func (c *TLSSelfSignedConfig) Validate() error
type TLSSelfSignedOption ¶
type TLSSelfSignedOption func(*tlsSelfSignedOptions)
TLSSelfSignedOption set tlsSelfSignedOptions.
func WithTLSSelfSignedCacheDir ¶
func WithTLSSelfSignedCacheDir(cacheDir string) TLSSelfSignedOption
WithTLSSelfSignedCacheDir sets the cache directory for self-signed certificates.
func WithTLSSelfSignedExpirationDays ¶
func WithTLSSelfSignedExpirationDays(expirationDays int) TLSSelfSignedOption
WithTLSSelfSignedExpirationDays sets the expiration days for self-signed certificates.
func WithTLSSelfSignedWanIPs ¶
func WithTLSSelfSignedWanIPs(wanIPs ...string) TLSSelfSignedOption
WithTLSSelfSignedWanIPs sets the IP addresses to include in the certificate.