tomlconfig

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package tomlconfig defines the TOML config for Web Packager HTTP Server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	MaxEntries int `default:"200"`
}

CacheConfig represents the [Cache] section.

type Config

type Config struct {
	Listen    ListenConfig
	Server    ServerConfig
	SXG       SXGConfig
	Sign      SignConfig
	Processor ProcessorConfig
	Cache     CacheConfig
}

Config defines the TOML config. See cmd/webpkgserver/webpkgserver.example.toml for detail.

func ParseConfig

func ParseConfig(data []byte) (*Config, error)

ParseConfig parses data into a Config. It also validates all fields and returns error if the validation fails.

func ReadFromFile

func ReadFromFile(filename string) (*Config, error)

ReadFromFile reads a Config from filename. It also validates all fields and returns error if the validation fails.

func (*Config) Verify

func (c *Config) Verify() error

Verify validates all fields in c. ReadFromFile and ParseConfig calls Verify internally, so you do not usually have to call it by yourself.

type Error

type Error struct {
	Name string
	Err  error
}

Error reports an error with TOML config.

func (*Error) Error

func (e *Error) Error() string

Error implements error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns e.Err.

type ListenConfig

type ListenConfig struct {
	Host string
	Port int
	TLS  TLSConfig
}

ListenConfig represents the [Listen] section.

type ProcessorConfig

type ProcessorConfig struct {
	SizeLimit  int `default:"4194304"`
	PreloadCSS bool
	PreloadJS  bool
}

ProcessorConfig represents the [Processor] section.

type SXGACMEConfig

type SXGACMEConfig struct {
	Enable            bool
	CSRFile           string
	DiscoveryURL      string
	Email             string
	EABKid            string
	EABHmac           string
	HTTPChallengePort int
	HTTPWebRootDir    string
	TLSChallengePort  int
	DNSProvider       string
}

SXGACMEConfig represents the [SXG.ACME] section.

type SXGCertConfig

type SXGCertConfig struct {
	PEMFile       string
	KeyFile       string
	CacheDir      string
	AllowTestCert bool
}

SXGCertConfig represents the [SXG.Cert] section.

type SXGConfig

type SXGConfig struct {
	Expiry             string `default:"168h"`
	JSExpiry           string `default:"24h"`
	CertURLBase        string `default:"/webpkg/cert"`
	ValidityURL        string `default:"/webpkg/validity"`
	KeepNonSXGPreloads bool
	Cert               SXGCertConfig
	ACME               SXGACMEConfig
}

SXGConfig represents the [SXG] section.

func (*SXGConfig) GetCertURLBase

func (c *SXGConfig) GetCertURLBase() *url.URL

GetCertURLBase returns a parsed c.CertURLBase. It panics if c.CertURLBase cannot be parsed; it should not happen if c is obtained using ParseConfig or ReadFromFile.

func (*SXGConfig) GetExpiry

func (c *SXGConfig) GetExpiry() time.Duration

GetExpiry returns a parsed c.Expiry. It panics if c.Expiry contains an invalid value; it should not happen if c is obtained using ParseConfig or ReadFromFile.

func (*SXGConfig) GetJSExpiry

func (c *SXGConfig) GetJSExpiry() time.Duration

GetJSExpiry returns a parsed c.JSExpiry. It panics if c.JSExpiry contains an invalid value; it should not happen if c is obtained using ParseConfig or ReadFromFile.

func (*SXGConfig) GetValidityURL

func (c *SXGConfig) GetValidityURL() *url.URL

GetValidityURL returns a parsed c.ValidityURL. It panics if c.ValidityURL cannot be parsed; it should not happen if c is obtained using ParseConfig or ReadFromFile.

type ServerConfig

type ServerConfig struct {
	DocPath      string `default:"/priv/doc"`
	CertPath     string `default:"/webpkg/cert"`
	ValidityPath string `default:"/webpkg/validity"`
	HealthPath   string `default:"/healthz"`
	SignParam    string `default:"sign"`
}

ServerConfig represents the [Server] section.

type SignConfig

type SignConfig []URLConfig

SignConfig represents the [[Sign]] sections.

type TLSConfig

type TLSConfig struct {
	PEMFile string
	KeyFile string
}

TLSConfig is part of ListenConfig.

type URLConfig

type URLConfig struct {
	Domain  string
	PathRE  string `default:".*"`
	QueryRE string `default:""`
}

URLConfig represents each of the [[Sign]] sections.

func (*URLConfig) GetPathRE

func (c *URLConfig) GetPathRE() *regexp.Regexp

GetPathRE returns a compiled c.PathRE. It also encloses the regexp with `\A(?:...)\z` to make it a full match. It panics if c.PathRE is malformed; it should not happen if c is obtained using ParseConfig or ReadFromFile.

func (*URLConfig) GetQueryRE

func (c *URLConfig) GetQueryRE() *regexp.Regexp

GetQueryRE returns a compiled c.QueryRE. It also encloses the regexp with `\A(?:...)\z` to make it a full match. It panics if c.PathRE is malformed; it should not happen if c is obtained using ParseConfig or ReadFromFile.

Jump to

Keyboard shortcuts

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