config

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 8 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Vroomy Config

Documentation

Index

Constants

View Source
const (
	// ErrInvalidPluginHandler is returned when a plugin handler is not valid
	ErrInvalidPluginHandler = errors.Error("plugin handler not valid")
	// ErrExpectedEndParen is returned when an ending parenthesis is missing
	ErrExpectedEndParen = errors.Error("expected ending parenthesis")
)
View Source
const (
	// ErrGroupNotFound is returned when a group cannot be found by name
	ErrGroupNotFound = errors.Error("group not found")
)
View Source
const (
	// ErrInvalidRoot is returned whe a root is longer than the request path
	ErrInvalidRoot = errors.Error("invalid root, cannot be longer than request path")
)
View Source
const (

	// ErrProtectedFlag is returned when a protected flag is used
	ErrProtectedFlag = errors.Error("cannot use protected flag")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name    string `toml:"name"`
	Usage   string `toml:"usage"`
	Require string `toml:"require"`

	Prehook  string `toml:"prehook"`
	Handler  string `toml:"handler"`
	Posthook string `toml:"posthook"`
}

Command represents a command entry

type Config

type Config struct {
	Name string `toml:"name"`

	Dir     string `toml:"dir"`
	Port    uint16 `toml:"port"`
	TLSPort uint16 `toml:"tlsPort"`
	TLSDir  string `toml:"tlsDir"`

	ErrorLogger func(error)

	IncludeConfig

	PerformUpdate bool `toml:"-"`

	Flags map[string]string `toml:"-"`

	// Plugin keys as they are referenced by the plugins store
	PluginKeys []string

	ExampleRequests  map[string]*Request
	ExampleResponses map[string]*Response
}

Config is the configuration needed to initialize a new instance of Service

func NewConfig

func NewConfig(loc string) (cfg *Config, err error)

NewConfig will return a new configuration

func (*Config) GetGroup

func (c *Config) GetGroup(name string) (g *Group, err error)

GetGroup will return group with name

type Flag

type Flag struct {
	Name         string `toml:"name"`
	DefaultValue string `toml:"defaultValue"`
	Usage        string `toml:"usage"`
}

Flag represents a flag entry

type Group

type Group struct {
	Name string `toml:"name"`
	// Route group
	Group string `toml:"group"`
	// HTTP method
	Method string `toml:"method"`
	// HTTP path
	HTTPPath string `toml:"httpPath"`
	// Plugin handlers
	Handlers []string `toml:"handlers"`

	HTTPHandlers []common.Handler `toml:"-"`

	G common.Group `toml:"-"`

	// Requests are keys to the request map which includes example request/response data for docs and tests
	Requests map[string]*Request
}

Group represents a route group

type IncludeConfig

type IncludeConfig struct {
	// Application environment
	Environment map[string]string `toml:"env"`

	// Allow included files to add includes
	Include []string `toml:"include"`

	// Specify which plugins are in scope
	Plugins []string `toml:"plugins"`

	// Commands are the dynamic commands specified in config
	CommandEntries []*Command `toml:"command"`
	// Flags are the dynamic flags specified in config
	FlagEntries []*Flag `toml:"flag"`

	// Groups are the route groups
	Groups []*Group `toml:"group"`
	// Routes are the routes to listen for and serve
	Routes []*Route `toml:"route"`

	// Requests are example requests for docs/tests
	Requests []*Request `toml:"request"`
	// Responses are example responses for docs/tests
	Responses []*Response `toml:"response"`
}

IncludeConfig will include routes

type PluginConfig

type PluginConfig struct {
	// Specify which plugins are in scope
	Plugins []string `toml:"plugins"`
}

PluginConfig is abbreviated import for vpm use case

type Request

type Request struct {
	// ID
	Name  string `toml:"name"`
	Group string `toml:"group"`

	Query map[string]string `toml:"query"`
	Body  map[string]string `toml:"body"`

	Responses        []string    `toml:"responses"`
	ResponseExamples []*Response `toml:"-"`

	// Links
	Parent string `toml:"parent"`
	// contains filtered or unexported fields
}

Request is an example requests for docs/tests

func (*Request) InheritFrom

func (r *Request) InheritFrom(parents map[string]*Request)

InheritFrom ensures family tree is populated and overridden

type Response

type Response struct {
	// ID
	Name string `toml:"name"`

	// Links
	Parent string `toml:"parent"`

	// Inheritable vals
	Code int               `toml:"code"`
	Data map[string]string `toml:"data"`
	// contains filtered or unexported fields
}

Response is an example response for docs/tests

func (*Response) InheritFrom

func (r *Response) InheritFrom(parents map[string]*Response)

InheritFrom ensures family tree is populated and overridden

type Route

type Route struct {
	// Target plug-in handler
	HTTPHandlers []common.Handler `toml:"-"`

	// Route name/description
	Name string `toml:"name"`
	// Route group
	Group string `toml:"group"`
	// HTTP method
	Method string `toml:"method"`
	// HTTP path
	HTTPPath string `toml:"httpPath"`
	// Directory or file to serve
	Target string `toml:"target"`
	// Plugin handlers
	Handlers []string `toml:"handlers"`

	RequestExample *Request
}

Route represents a listening route

func (*Route) String

func (r *Route) String() string

String will return a formatted version of the route

Jump to

Keyboard shortcuts

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