config

package
v0.0.0-...-0f53290 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Handlers = map[string]func(logger *slog.Logger, u, cacheControle string) http.Handler{
	"f": handlers.File,
	"m": handlers.Cache,
	"r": handlers.Redirect,
	"s": handlers.Secure,
	"p": handlers.ReverseProxy,
}

Map of config handlers. The key is used in the config file. The value is used when initiate the server to create the handlers.

You can add your cutom handler to this map at init.

Functions

func Listen

func Listen(configFile string)

Liten on all multiplexer. Return if the load of config file fail or all multiplexer listen fail.

func Main

func Main()

Standard demon main. Usage: init your custom handlers, then just call this in your main func.

Types

type Cert

type Cert struct {
	Root string
	Key  string
	Crt  string
}

type Config

type Config struct {
	// Log output directory
	Log string
	// Multiplexors, the key is the listened address `[IP]:port`
	Mux map[string]Mux
}

func ReadFile

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

Decode toml file into a Config structure.

type Handler

type Handler struct {
	// Type of the handler.
	// f: file
	// m: file with memory cache
	// r: redirect
	// s: redirect to HTTPS, ignore .U field
	// Future version
	// p: reverse proxy
	Type string `toml:"t"`
	// A URL, for file root, URL for redirect or reverse serv...
	URL string `toml:"u"`
	// Cache control instruction.
	Cache string `toml:"c"`
}

type Mux

type Mux struct {
	// TLS certificates position.
	// Is any, do no use TLS.
	Cert []Cert
	// Handlers config, indexed by domain and path
	Handlers map[string]Handler `toml:"h"`
}

func (*Mux) Listen

func (mux *Mux) Listen(logger *slog.Logger, address string) error

func (Mux) LoadTLS

func (mux Mux) LoadTLS() (*tls.Config, error)

Jump to

Keyboard shortcuts

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