configuration

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MPL-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromLocal

func FromLocal(loc string) []byte

FromLocal loads a configuration file on a local location into bytes.

Types

type Config

type Config struct {
	Server  Server   `yaml:"server"`
	Servers []Server `yaml:"servers"`
}

Config - A config represents the root node of the structures.

func LoadConfig

func LoadConfig(location string, loaders ...(func(string) []byte)) *Config

LoadConfig use the given loader functions to retrieve a config data. Multiple loaders are tried one by one. FromLocal is an example loader function.

type Handler

type Handler struct {
	Path   string            `yaml:"path"`
	Type   string            `yaml:"type"`
	Config map[string]string `yaml:"config"`
}

Handler - A handler represents an HTTP handler listening to a path and having a type and its own configuration.

type Middleware

type Middleware struct {
	Type   string            `yaml:"type"`
	Config map[string]string `yaml:"config"`
}

Middleware - A middlware represents an HTTP middleware having a type and its own configuration.

type Router

type Router struct {
	Prefix      string       `yaml:"prefix"`
	Middlewares []Middleware `yaml:"middlewares"`
	Handlers    []Handler    `yaml:"handlers"`
}

Router - A router contains a prefix-defined routing rule, and underlying middlewares and handlers.

type Server

type Server struct {
	Port    string                       `yaml:"port"`
	Configs map[string]map[string]string `yaml:"configs"`
	Routers []Router                     `yaml:"routers"`
}

Server - A server represents a concept like an HTTP virtual server having its own port and containing zero to multiple routing rules.

Jump to

Keyboard shortcuts

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