config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2019 License: BSD-3-Clause Imports: 11 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

This section is empty.

Types

type App

type App struct {
	// MaxReqSize defines the maximum request size in bytes
	MaxReqSize uint64

	// MaxFileSize defines the maximum file size in bytes
	MaxFileSize uint64

	// MaxMultipartMembuf defines the maximum multipart/form-data memory buffer
	MaxMultipartMembuf uint64
}

App represents the application configurations

type Config

type Config struct {
	Mode          Mode
	TransportHTTP *TransportHTTP
	DebugLog      *log.Logger
	ErrorLog      *log.Logger
	App           App
}

Config defines the API server configurations

func FromFile

func FromFile(path string) (*Config, error)

FromFile reads the configuration from a file

func (*Config) Init

func (conf *Config) Init() error

Init sets defaults and validates the configurations

type Duration

type Duration time.Duration

Duration represents a duration

func (*Duration) UnmarshalTOML

func (v *Duration) UnmarshalTOML(val interface{}) error

UnmarshalTOML implements the TOML unmarshaler interface

type File

type File struct {
	Mode Mode `toml:"mode"`
	Log  struct {
		Debug string `toml:"debug"`
		Error string `toml:"error"`
	} `toml:"log"`
	TransportHTTP struct {
		Host              string   `toml:"host"`
		KeepAliveDuration Duration `toml:"keep-alive-duration"`
		TLS               struct {
			Enabled          bool             `toml:"enabled"`
			MinVersion       TLSVersion       `toml:"min-version"`
			CertificateFile  string           `toml:"certificate-file"`
			KeyFile          string           `toml:"key-file"`
			CurvePreferences []TLSCurveID     `toml:"curve-preferences"`
			CipherSuites     []TLSCipherSuite `toml:"cipher-suites"`
		} `toml:"tls"`
	} `toml:"transport-http"`
	App struct {
		MaxReqSize         string `toml:"max-req-size"`
		MaxFileSize        string `toml:"max-file-size"`
		MaxMultipartMembuf string `toml:"max-multipart-membuf"`
	} `toml:"app"`
}

File represents a TOML encoded configuration file

type Mode

type Mode string

Mode defines the server mode

const (
	// ModeDebug represents the debug server mode
	ModeDebug Mode = "debug"

	// ModeBeta represents the beta server mode
	ModeBeta Mode = "beta"

	// ModeProduction represents the production server mode
	ModeProduction Mode = "production"
)

func (Mode) Validate

func (md Mode) Validate() error

Validate returns an error if the mode is unknown

type TLSCipherSuite

type TLSCipherSuite uint16

TLSCipherSuite represents a TLS cipher suite

func (*TLSCipherSuite) UnmarshalTOML

func (v *TLSCipherSuite) UnmarshalTOML(val interface{}) error

UnmarshalTOML implements the TOML unmarshaler interface

type TLSCurveID

type TLSCurveID tls.CurveID

TLSCurveID represents a TLS curve identifier

func (*TLSCurveID) UnmarshalTOML

func (v *TLSCurveID) UnmarshalTOML(val interface{}) error

UnmarshalTOML implements the TOML unmarshaler interface

type TLSVersion

type TLSVersion uint16

TLSVersion represents a TLS protocol version

func (*TLSVersion) UnmarshalTOML

func (v *TLSVersion) UnmarshalTOML(val interface{}) error

UnmarshalTOML implements the TOML unmarshaler interface

type TransportHTTP

type TransportHTTP struct {
	Host              string
	KeepAliveDuration time.Duration
	TLS               *TransportHTTPTLS
}

TransportHTTP defines the HTTP server transport layer configurations

func (*TransportHTTP) Init

func (conf *TransportHTTP) Init() error

Init sets defaults and validates the configurations

type TransportHTTPTLS

type TransportHTTPTLS struct {
	Config              *tls.Config
	CertificateFilePath string
	PrivateKeyFilePath  string
}

TransportHTTPTLS represents the TLS configurations

func (*TransportHTTPTLS) Clone

func (stls *TransportHTTPTLS) Clone() *TransportHTTPTLS

Clone creates an exact detached copy of the server TLS configurations

Jump to

Keyboard shortcuts

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