config

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultListen     = ":8080"
	DefaultServerName = "fasthttpd"
)

Default values.

View Source
const (
	MatchPrefix = "prefix"
	MatchEqual  = "equal"
	MatchRegexp = "regexp"
)

Supported Route.Match values.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLog

type AccessLog struct {
	Output    string `yaml:"output"`
	Format    string `yaml:"format"`
	QueueSize int    `yaml:"queueSize"`
	Rotation  Rotation
}

AccessLog represents a configuration of access log.

func (AccessLog) SetDefaults added in v0.1.0

func (l AccessLog) SetDefaults() AccessLog

SetDefaults sets default values.

type Config

type Config struct {
	Host        string              `yaml:"host"`
	Listen      string              `yaml:"listen"`
	SSL         SSL                 `yaml:"ssl"`
	Root        string              `yaml:"root"`
	Server      tree.Map            `yaml:"server"`
	Log         Log                 `yaml:"log"`
	AccessLog   AccessLog           `yaml:"accessLog"`
	ErrorPages  map[string]string   `yaml:"errorPages"`
	Filters     map[string]tree.Map `yaml:"filters"`
	Handlers    map[string]tree.Map `yaml:"handlers"`
	Routes      []Route             `yaml:"routes"`
	RoutesCache RoutesCache         `yaml:"routesCache"`
	Include     string              `yaml:"include"`
}

Config represents a configuration root of fasthttpd. If Include is not empty, other keys are ignored.

func UnmarshalYAML

func UnmarshalYAML(data []byte) ([]Config, error)

UnmarshalYAML decodes data as multi Config YAML documents.

func UnmarshalYAMLPath

func UnmarshalYAMLPath(path string) ([]Config, error)

UnmarshalYAMLPath decodes path as multi Config YAML documents file.

func (Config) Normalize

func (cfg Config) Normalize() (Config, error)

Normalize normalizes values.

func (Config) SetDefaults added in v0.1.0

func (cfg Config) SetDefaults() Config

SetDefaults sets default values.

type Log

type Log struct {
	Output   string   `yaml:"output"`
	Prefix   string   `yaml:"prefix"`
	Flags    []string `yaml:"flags"`
	Rotation Rotation
}

Log represents a configuration of logging.

func (Log) SetDefaults added in v0.1.0

func (l Log) SetDefaults() Log

SetDefaults sets default values.

type Rotation added in v0.1.0

type Rotation struct {
	MaxSize    int  `yaml:"maxSize"`
	MaxBackups int  `yaml:"maxBackups"`
	MaxAge     int  `yaml:"maxAge"`
	Compress   bool `yaml:"compress"`
	LocalTime  bool `yaml:"localTime"`
}

Rotation represents a configuration of log rotation.

func (Rotation) SetDefaults added in v0.1.0

func (r Rotation) SetDefaults() Rotation

SetDefaults sets default values.

type Route

type Route struct {
	Path                     string   `yaml:"path"`
	Match                    string   `yaml:"match"`
	Methods                  []string `yaml:"methods"`
	Filters                  []string `yaml:"filters"`
	Rewrite                  string   `yaml:"rewrite"`
	RewriteAppendQueryString bool     `yaml:"rewriteAppendQueryString"`
	Handler                  string   `yaml:"handler"`
	Status                   int      `yaml:"status"`
	StatusMessage            string   `yaml:"statusMessage"`
	NextIfNotFound           bool     `yaml:"nextIfNotFound"`
}

Route represents a configuration of route.

type RoutesCache

type RoutesCache struct {
	Enable   bool `yaml:"enable"`
	Expire   int  `yaml:"expire"`
	Interval int  `yaml:"interval"`
}

RoutesCache represents a configuration of route cache.

type SSL added in v0.2.0

type SSL struct {
	CertFile         string `yaml:"certFile"`
	KeyFile          string `yaml:"keyFile"`
	AutoCert         bool   `yaml:"autoCert"`
	AutoCertCacheDir string `yaml:"autoCertCacheDir"`
}

SSL represents a configuration of SSL. If AutoCert is true, CertFile and KeyFile are ignored.

func (SSL) Normalize added in v0.3.6

func (ssl SSL) Normalize() (SSL, error)

Normalize normalizes values.

func (SSL) SetDefaults added in v0.3.6

func (ssl SSL) SetDefaults() SSL

SetDefaults sets default values.

Jump to

Keyboard shortcuts

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