config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConfigFromFileOrEnv

func InitConfigFromFileOrEnv(file string)

InitConfigFromFileOrEnv - Init the configuration in sequence: from a YAML file, from environment variables, then defaults.

func Print

func Print()

Print - Shows the current configuration.

func Validate

func Validate(file string) (bool, error)

Validate - Validate a YAML config file is syntactically valid.

Types

type Cache

type Cache struct {
	Host            string   `yaml:"host"`
	Port            string   `yaml:"port"`
	Password        string   `yaml:"password"`
	DB              int      `yaml:"db"`
	TTL             int      `yaml:"ttl"`
	AllowedStatuses []int    `yaml:"allowed_statuses"`
	AllowedMethods  []string `yaml:"allowed_methods"`
}

Cache - Defines the config for the cache backend

type Configuration

type Configuration struct {
	Server         Server                        `yaml:"server"`
	Cache          Cache                         `yaml:"cache"`
	CircuitBreaker circuitbreaker.CircuitBreaker `yaml:"circuit_breaker"`
	Domains        Domains                       `yaml:"domains"`
	Log            Log                           `yaml:"log"`
}

Configuration - Defines the server configuration

var Config Configuration = Configuration{
	Server: Server{
		Port: Port{
			HTTP:  "80",
			HTTPS: "443",
		},
		TLS: TLS{
			Auto:     false,
			Email:    "",
			CertFile: "",
			KeyFile:  "",
			Override: &tls.Config{

				CurvePreferences: []tls.CurveID{
					tls.CurveP256,
				},
				MinVersion: tls.VersionTLS12,
				MaxVersion: tls.VersionTLS13,
				CipherSuites: []uint16{
					tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
					tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
					tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
					tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,

					tls.TLS_AES_128_GCM_SHA256,
					tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
					tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
				},
			},
		},
		Timeout: Timeout{
			Read:       5 * time.Second,
			ReadHeader: 2 * time.Second,
			Write:      5 * time.Second,
			Idle:       20 * time.Second,
			Handler:    5 * time.Second,
		},
		Upstream: Upstream{
			HTTP2HTTPS:         false,
			InsecureBridge:     false,
			RedirectStatusCode: 301,
		},
		GZip:        false,
		Healthcheck: true,
	},
	Cache: Cache{
		Port:            "6379",
		DB:              0,
		TTL:             0,
		AllowedStatuses: []int{200, 301, 302},
		AllowedMethods:  []string{"HEAD", "GET"},
	},
	CircuitBreaker: circuitbreaker.CircuitBreaker{
		Threshold:   2,
		FailureRate: 0.5,
		Interval:    0,
		Timeout:     60 * time.Second,
		MaxRequests: 1,
	},
	Log: Log{
		TimeFormat: "2006/01/02 15:04:05",
		Format:     `$host - $remote_addr - $remote_user $protocol $request_method "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $cached_status`,
	},
}

Config - Holds the server configuration

func CopyOverWith

func CopyOverWith(base Configuration, overrides Configuration, file *string) Configuration

CopyOverWith - Copies the Configuration over another (preserving not defined settings).

func DomainConf

func DomainConf(domain string, scheme string) *Configuration

DomainConf - Returns the configuration for the requested domain.

type DomainSet added in v0.2.0

type DomainSet struct {
	Host   string
	Scheme string
}

DomainSet - Holds the uniqueness details of the domain

func GetDomains

func GetDomains() []DomainSet

GetDomains - Returns a list of domains.

type Domains

type Domains map[string]Configuration

Domains - Overrides per domain

type Log

type Log struct {
	TimeFormat string `yaml:"time_format"`
	Format     string `yaml:"format"`
}

Log - Defines the config for the logs

type Port

type Port struct {
	HTTP  string `yaml:"http"`
	HTTPS string `yaml:"https"`
}

Port - Defines the listening ports per protocol

type Server

type Server struct {
	Port        Port     `yaml:"port"`
	TLS         TLS      `yaml:"tls"`
	Timeout     Timeout  `yaml:"timeout"`
	Upstream    Upstream `yaml:"upstream"`
	GZip        bool     `yaml:"gzip"`
	Healthcheck bool     `yaml:"healthcheck"`
}

Server - Defines basic info for the server

type TLS

type TLS struct {
	Auto     bool        `yaml:"auto"`
	Email    string      `yaml:"email"`
	CertFile string      `yaml:"cert_file"`
	KeyFile  string      `yaml:"key_file"`
	Override *tls.Config `yaml:"override"`
}

TLS - Defines the configuration for SSL/TLS

type Timeout

type Timeout struct {
	Read       time.Duration `yaml:"read"`
	ReadHeader time.Duration `yaml:"read_header"`
	Write      time.Duration `yaml:"write"`
	Idle       time.Duration `yaml:"idle"`
	Handler    time.Duration `yaml:"handler"`
}

Timeout - Defines the server timeouts

type Upstream

type Upstream struct {
	Host               string   `yaml:"host"`
	Port               string   `yaml:"port"`
	Scheme             string   `yaml:"scheme"`
	Endpoints          []string `yaml:"endpoints"`
	InsecureBridge     bool     `yaml:"insecure_bridge"`
	HTTP2HTTPS         bool     `yaml:"http_to_https"`
	RedirectStatusCode int      `yaml:"redirect_status_code"`
}

Upstream - Defines the upstream settings

Jump to

Keyboard shortcuts

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