config

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort = "80"
	DefaultHost = "127.0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name    string  `yaml:"name"`
	Options Options `yaml:"options"`
	Routes  []Route `yaml:"routes"`
}

func LoadConfigFromFile

func LoadConfigFromFile(cfgPath string) (Config, error)

LoadConfigFromFile attempts to load the config from the given file path.

func (*Config) OverrideFromCommand

func (c *Config) OverrideFromCommand(cmd *cobra.Command)

type Options

type Options struct {
	// When a request body is received, attempt to print the value to the console
	// after the table record.
	PrintRequestBody bool `yaml:"printRequestBody"`

	TrackRequests bool `yaml:"trackRequests"`

	Port string `yaml:"port"`
	Host string `yaml:"host"`
}

type Route

type Route struct {
	Path       string         `yaml:"path" json:"path"`
	Method     string         `yaml:"method" json:"method"`
	StatusCode int            `yaml:"statusCode" json:"statusCode"`
	Response   string         `yaml:"response" json:"response"`
	Variants   []RouteVariant `yaml:"variants,omitempty" json:"variants"`
	Delay      int            `yaml:"delay"`
}

type RouteVariant

type RouteVariant struct {
	Params     map[string]string `yaml:"params" json:"params"`
	StatusCode int               `yaml:"statusCode" json:"statusCode"`
	Response   string            `yaml:"response" json:"response"`
}

Jump to

Keyboard shortcuts

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