config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SOURCE_STDIN = "@source:stdin"
	SOURCE_FILE  = "@source:file"
	SOURCE_URL   = "@source:url"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Source    string `yaml:"source"`
	ConfigURI string `yaml:"config-uri"`

	Port int `yaml:"port"`

	CacheTTL time.Duration `yaml:"cache-ttl"`
	LoadedAt time.Time     `yaml:"loaded-at"`

	TempRedirect bool `yaml:"temp-redirect"`

	Redirects []Redirect `yaml:"redirects"`
}

func LoadConfig

func LoadConfig(ctx context.Context, readStdin bool, filePath, url string) *Config

func NewConfig

func NewConfig(source, uri string) *Config

func (*Config) CopyFrom

func (c *Config) CopyFrom(other *Config)

Copy configurations from another config

func (*Config) GetRedirect

func (c *Config) GetRedirect(host string) *Redirect

Gets the redirection that matches the given domain

func (*Config) Load

func (c *Config) Load() error

func (Config) String

func (c Config) String() string

Prints the config as yaml

func (*Config) Validate

func (c *Config) Validate() error

Validates the config

type Redirect

type Redirect struct {
	From         string `yaml:"from"`
	To           string `yaml:"to"`
	PreservePath bool   `yaml:"preserve-path"`
	TempRedirect *bool  `yaml:"temp-redirect"`
}

Jump to

Keyboard shortcuts

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