config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2015 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package config contains utilities and types necessary for launching specially-configured server instances.

Index

Constants

View Source
const (

	// The default configuration file to load if none is specified
	DefaultConfigFile = "Caddyfile"
)

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns whether or not the error is one which indicates that the configuration file was not found. (Useful for checking the error returned from Load).

Types

type Config

type Config struct {
	// The hostname or IP on which to serve
	Host string

	// The port to listen on
	Port string

	// The directory from which to serve files
	Root string

	// HTTPS configuration
	TLS TLSConfig

	// Middleware stack
	Middleware map[string][]middleware.Middleware

	// Functions (or methods) to execute at server start; these
	// are executed before any parts of the server are configured,
	// and the functions are blocking
	Startup []func() error

	// Functions (or methods) to execute when the server quits;
	// these are executed in response to SIGINT and are blocking
	Shutdown []func() error

	// The path to the configuration file from which this was loaded
	ConfigFile string
}

config represents a server configuration. It is populated by parsing a config file (via the Load function).

func Default

func Default() []Config

Default makes a default configuration that's empty except for root, host, and port, which are essential for serving the cwd.

func Load

func Load(filename string) ([]Config, error)

Load loads a configuration file, parses it, and returns a slice of Config structs which can be used to create and configure server instances.

func (Config) Address

func (c Config) Address() string

Address returns the host:port of c as a string.

type TLSConfig

type TLSConfig struct {
	Enabled     bool
	Certificate string
	Key         string
}

TLSConfig describes how TLS should be configured and used, if at all. A certificate and key are both required.

Jump to

Keyboard shortcuts

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