config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExpirationTime = 30 * time.Minute
	DefaultClearTime      = 30 * time.Minute
)

Variables

View Source
var (
	ErrNoToPair   = errors.New("`to` values are not set for every `from`")
	ErrNoFromPair = errors.New("`from` values are not set for every `to`")
)

Functions

func StaticDirMappingHookFunc added in v0.1.0

func StaticDirMappingHookFunc() mapstructure.DecodeHookFunc

func StringToTimeDurationHookFunc added in v0.2.0

func StringToTimeDurationHookFunc() mapstructure.DecodeHookFunc

func URLMappingHookFunc added in v0.1.0

func URLMappingHookFunc() mapstructure.DecodeHookFunc

Types

type CacheConfig added in v0.2.0

type CacheConfig struct {
	ExpirationTime time.Duration `mapstructure:"expiration-time"`
	ClearTime      time.Duration `mapstructure:"clear-time"`
	Methods        []string      `mapstructure:"methods"`
}

func (*CacheConfig) Clone added in v0.2.0

func (c *CacheConfig) Clone() *CacheConfig

type CacheGlobs added in v0.2.0

type CacheGlobs []string

func (CacheGlobs) Clone added in v0.2.0

func (g CacheGlobs) Clone() CacheGlobs

type Mapping added in v0.1.0

type Mapping struct {
	From            string            `mapstructure:"from"`
	To              string            `mapstructure:"to"`
	Statics         StaticDirectories `mapstructure:"statics"`
	Mocks           Mocks             `mapstructure:"mocks"`
	Scripts         Scripts           `mapstructure:"scripts"`
	Cache           CacheGlobs        `mapstructure:"cache"`
	Rewrites        RewriteOptions    `mapstructure:"rewrites"`
	OptionsHandling OptionsHandling   `mapstructure:"options-handling"`
	// contains filtered or unexported fields
}

func (*Mapping) ClearCache added in v0.6.0

func (m *Mapping) ClearCache()

ClearCache clears the cached URL and its components. This is primarily used for testing.

func (*Mapping) Clone added in v0.1.0

func (m *Mapping) Clone() Mapping

func (*Mapping) GetFromHostPort added in v0.6.0

func (m *Mapping) GetFromHostPort() (string, string, error)

GetFromHostPort returns the host and port from the From URL, caching them on first access. This method combines URL parsing and host/port splitting to avoid redundant operations.

func (*Mapping) GetFromURL added in v0.6.0

func (m *Mapping) GetFromURL() (*url.URL, error)

GetFromURL returns the parsed URL, caching it on first access. This method performs lazy parsing to avoid redundant URL parsing operations.

type Mappings added in v0.1.0

type Mappings []Mapping

func NormaliseMappings added in v0.1.0

func NormaliseMappings(mappings Mappings) Mappings

func (Mappings) GroupByPort added in v0.6.0

func (m Mappings) GroupByPort() PortGroups

func (Mappings) String added in v0.1.0

func (m Mappings) String() string

type Mock added in v0.1.0

type Mock struct {
	Matcher  RequestMatcher `mapstructure:",squash"`
	Response Response       `mapstructure:"response"`
}

func (*Mock) Clone added in v0.1.0

func (m *Mock) Clone() Mock

func (*Mock) String added in v0.2.0

func (m *Mock) String() string

type Mocks added in v0.1.0

type Mocks []Mock

func (Mocks) Clone added in v0.1.0

func (m Mocks) Clone() Mocks

type OptionsHandling added in v0.5.0

type OptionsHandling struct {
	Disabled bool              `mapstructure:"disabled"`
	Headers  map[string]string `mapstructure:"headers"`
	Code     int               `mapstructure:"code"`
}

func (*OptionsHandling) Clone added in v0.5.0

func (o *OptionsHandling) Clone() OptionsHandling

type PortGroup added in v0.6.0

type PortGroup struct {
	Port     int
	Scheme   string
	Mappings Mappings
}

type PortGroups added in v0.6.0

type PortGroups []PortGroup

type RequestMatcher added in v0.6.0

type RequestMatcher struct {
	Path    string            `mapstructure:"path"`
	Method  string            `mapstructure:"method"`
	Queries map[string]string `mapstructure:"queries"`
	Headers map[string]string `mapstructure:"headers"`
}

func (*RequestMatcher) Clone added in v0.6.0

func (r *RequestMatcher) Clone() RequestMatcher

func (*RequestMatcher) IsPathOnly added in v0.6.0

func (r *RequestMatcher) IsPathOnly() bool

type Response added in v0.1.0

type Response struct {
	Code    int               `mapstructure:"code"`
	Headers map[string]string `mapstructure:"headers"`
	Delay   time.Duration     `mapstructure:"delay"`
	Raw     string            `mapstructure:"raw"`
	File    string            `mapstructure:"file"`
}

func (*Response) Clone added in v0.1.0

func (r *Response) Clone() Response

func (*Response) IsFile added in v0.3.0

func (r *Response) IsFile() bool

func (*Response) IsRaw added in v0.3.0

func (r *Response) IsRaw() bool

type RewriteOptions added in v0.4.0

type RewriteOptions []RewritingOption

func (RewriteOptions) Clone added in v0.4.0

func (r RewriteOptions) Clone() RewriteOptions

type RewritingOption added in v0.4.0

type RewritingOption struct {
	From string `mapstructure:"from"`
	To   string `mapstructure:"to"`
	Host string `mapstructure:"host"`
}

func (RewritingOption) Clone added in v0.4.0

func (r RewritingOption) Clone() RewritingOption

type Script added in v0.6.0

type Script struct {
	Matcher RequestMatcher `mapstructure:",squash"`
	Script  string         `mapstructure:"script"`
	File    string         `mapstructure:"file"`
}

func (*Script) Clone added in v0.6.0

func (s *Script) Clone() Script

func (*Script) String added in v0.6.0

func (s *Script) String() string

type Scripts added in v0.6.0

type Scripts []Script

func (Scripts) Clone added in v0.6.0

func (s Scripts) Clone() Scripts

type StaticDirectories added in v0.1.0

type StaticDirectories []StaticDirectory

func (StaticDirectories) Clone added in v0.1.0

type StaticDirectory added in v0.1.0

type StaticDirectory struct {
	Path  string `mapstructure:"path"`
	Dir   string `mapstructure:"dir"`
	Index string `mapstructure:"index"`
}

func (*StaticDirectory) Clone added in v0.1.0

func (s *StaticDirectory) Clone() StaticDirectory

func (*StaticDirectory) String added in v0.2.0

func (s *StaticDirectory) String() string

type UncorsConfig added in v0.1.0

type UncorsConfig struct {
	HTTPPort    int         `mapstructure:"http-port"`
	Mappings    Mappings    `mapstructure:"mappings"`
	Proxy       string      `mapstructure:"proxy"`
	Debug       bool        `mapstructure:"debug"`
	CacheConfig CacheConfig `mapstructure:"cache-config"`
}

func LoadConfiguration added in v0.1.0

func LoadConfiguration(viperInstance *viper.Viper, args []string) *UncorsConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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