Documentation
¶
Overview ¶
Package config defines the vuego-cli configuration file format.
A configuration file declares the virtual hosts a single vuego-cli process serves. Each entry binds a DNS host name to a content folder and the mode used to render it, which lets one process sit behind a reverse proxy and serve several documentation sites from one folder tree.
vhost:
- domain: docs.example.com docs.localhost
path: ./content/docs
mode: docs
- domain: tour.example.com
path: ./content/vuego-tour
mode: tour
A domain field holding several space separated names serves the same content on each of them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultFilenames = []string{"vuego-cli.yml", "vuego-cli.yaml"}
DefaultFilenames lists the configuration files looked up by Find, in order.
var ErrNotFound = errors.New("no configuration file found")
ErrNotFound is returned by Find when no default configuration file exists.
Functions ¶
func Find ¶
Find returns the path of the first default configuration file present in dir. It returns ErrNotFound when none of DefaultFilenames exists.
func FindFS ¶
FindFS returns the name of the first default configuration file present in fsys. It returns ErrNotFound when none of DefaultFilenames exists.
func NormalizeHost ¶
NormalizeHost reduces a host name to the form used for matching: lower case, without a port, and without the trailing dot of a fully qualified name. IPv6 literals keep their brackets.
Types ¶
type Config ¶
type Config struct {
// Addr is the address the HTTP server listens on. When empty the
// command line default applies.
Addr string `yaml:"addr"`
// TrustForwardedHost routes by the X-Forwarded-Host header when it is
// present, for proxies that rewrite Host on the way through. Leave it
// off unless the process is only reachable through such a proxy: any
// client that can reach the server can set the header.
TrustForwardedHost bool `yaml:"trust_forwarded_host"`
// VHosts are the virtual hosts this process serves.
VHosts []VHost `yaml:"vhost"`
}
Config is the vuego-cli configuration document.
func Decode ¶
Decode parses a configuration document without resolving paths or validating it. Load is the usual entry point; Decode exists for callers that supply the document from somewhere other than the filesystem.
func Load ¶
Load reads, decodes and validates the configuration file at path. Relative vhost paths are resolved against the directory holding the file, so a configuration is independent of the process working directory.
func LoadFS ¶
LoadFS reads, decodes and validates the configuration file named name in fsys. Relative vhost paths are resolved against base, which is the directory the configuration is considered to live in.
func (*Config) Resolve ¶
Resolve rewrites relative vhost paths so they are anchored at base, and normalizes domain names for matching. It is idempotent.
func (*Config) Validate ¶
Validate reports the first problem found in the configuration document. It checks the document only and does not touch the filesystem; whether a vhost's path exists is settled when its content filesystem is opened.
A configuration with no vhost entries is an error: an empty file is a mistake, and the caller falls back to serving the working directory only when no file exists at all.
type Mode ¶
type Mode string
Mode selects the server implementation used for a virtual host.
const ( // ModeDocs renders a markdown documentation tree with the basecoat theme. ModeDocs Mode = "docs" // ModeTour renders a tour: numbered chapter files split into lessons. ModeTour Mode = "tour" // ModeServe is the development server: vuego templates, LESS stylesheets // and static files served straight from the folder. ModeServe Mode = "serve" )
The available modes. Each corresponds to an existing vuego-cli command.
type VHost ¶
type VHost struct {
// Domain is the host name matched against the request, or several of
// them separated by spaces, which serves the same content on every
// name listed. Matching is case insensitive and ignores the port.
Domain string `yaml:"domain"`
// Path is the folder served for this domain. It is the full content
// root: point it at the nested folder if the documents do not live at
// the top of a checkout. Relative paths resolve against the directory
// holding the configuration file.
Path string `yaml:"path"`
// Mode selects the server: docs, tour or serve.
Mode Mode `yaml:"mode"`
}
VHost binds one or more domain names to a content folder and a rendering mode.