config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	File           string            `yaml:"file"`
	TemplateName   string            `yaml:"templateName"`
	AdditionalData map[string]string `yaml:"additionalData,omitempty"`
	Defaults       *LayerParams      `yaml:"defaults,omitempty"`
	Overrides      *LayerParams      `yaml:"overrides,omitempty"`
}

func (*Command) ExpandPaths

func (c *Command) ExpandPaths() error

type CommandDir

type CommandDir struct {
	Repositories               []string          `yaml:"repositories"`
	IncludeDefaultRepositories bool              `yaml:"includeDefaultRepositories"`
	TemplateDirectory          string            `yaml:"templateDirectory,omitempty"`
	TemplateName               string            `yaml:"templateName,omitempty"`
	IndexTemplateName          string            `yaml:"indexTemplateName,omitempty"`
	AdditionalData             map[string]string `yaml:"additionalData,omitempty"`
	Defaults                   *LayerParams      `yaml:"defaults,omitempty"`
	Overrides                  *LayerParams      `yaml:"overrides,omitempty"`
}

func (*CommandDir) ExpandPaths

func (c *CommandDir) ExpandPaths() error

type Config

type Config struct {
	Routes []*Route `yaml:"routes"`
}

func ParseConfig

func ParseConfig(data []byte) (*Config, error)

type LayerParams

type LayerParams struct {
	Layers    map[string]map[string]interface{} `yaml:"layers,omitempty"`
	Flags     map[string]interface{}            `yaml:"flags,omitempty"`
	Arguments map[string]interface{}            `yaml:"arguments,omitempty"`
}

func NewLayerParams

func NewLayerParams() *LayerParams

func (*LayerParams) Merge

func (p *LayerParams) Merge(overrides *LayerParams)

Merge merges the two LayerParams, with the overrides taking precedence. It merges all the layers, flags, and arguments. For each layer, the layer flags are merged as well, overrides taking precedence.

type Route

type Route struct {
	Path              string       `yaml:"path"`
	CommandDirectory  *CommandDir  `yaml:"commandDirectory,omitempty"`
	Command           *Command     `yaml:"command,omitempty"`
	Static            *Static      `yaml:"static,omitempty"`
	StaticFile        *StaticFile  `yaml:"staticFile,omitempty"`
	TemplateDirectory *TemplateDir `yaml:"templateDirectory,omitempty"`
	Template          *Template    `yaml:"template,omitempty"`

	DefaultStaticDirectory   bool `yaml:"defaultStaticDirectory,omitempty"`
	DefaultTemplateDirectory bool `yaml:"defaultTemplateDirectory,omitempty"`
}

Route represents a single sub-route of the server. Only one of the booleans or one of the pointers should be true or non-nil. This is the first attempt at the structure of a config file, and is bound to change.

func (*Route) HandlesCommand

func (r *Route) HandlesCommand() bool

func (*Route) HandlesStatic

func (r *Route) HandlesStatic() bool

func (*Route) HandlesTemplate

func (r *Route) HandlesTemplate() bool

func (*Route) IsCommandDirRoute

func (r *Route) IsCommandDirRoute() bool

func (*Route) IsCommandRoute

func (r *Route) IsCommandRoute() bool

func (*Route) IsStaticFileRoute

func (r *Route) IsStaticFileRoute() bool

func (*Route) IsStaticRoute

func (r *Route) IsStaticRoute() bool

func (*Route) IsTemplateDirRoute

func (r *Route) IsTemplateDirRoute() bool

func (*Route) IsTemplateRoute

func (r *Route) IsTemplateRoute() bool

type RouteHandlerConfiguration

type RouteHandlerConfiguration interface {
	//
	ExpandPaths() error
}

RouteHandlerConfiguration is the interface that all route handler configurations must implement. By RouteHandlerConfiguration, we mean things like CommandDir, Command, Static, etc...

type Static

type Static struct {
	LocalPath string `yaml:"localPath"`
}

func (*Static) ExpandPaths

func (s *Static) ExpandPaths() error

type StaticFile

type StaticFile struct {
	LocalPath string `yaml:"localPath"`
}

func (*StaticFile) ExpandPaths

func (s *StaticFile) ExpandPaths() error

type Template

type Template struct {
	// every request will be rendered from the template file
	TemplateFile string `yaml:"templateFile"`
}

func (*Template) ExpandPaths

func (t *Template) ExpandPaths() error

type TemplateDir

type TemplateDir struct {
	LocalDirectory    string                 `yaml:"localDirectory"`
	IndexTemplateName string                 `yaml:"indexTemplateName,omitempty"`
	AdditionalData    map[string]interface{} `yaml:"additionalData,omitempty"`
}

func (*TemplateDir) ExpandPaths

func (t *TemplateDir) ExpandPaths() error

Jump to

Keyboard shortcuts

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