killgrave

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachWatcher added in v0.4.0

func AttachWatcher(w *watcher.Watcher, fn func())

AttachWatcher start the watcher, if any error was produced while the starting process the application would crash you need to pass a function, this function is the function that will be executed when the watcher receive any event the type of defined on the InitializeWatcher function

func CloseWatcher added in v0.5.0

func CloseWatcher(w *watcher.Watcher)

func InitializeWatcher added in v0.4.0

func InitializeWatcher(pathToWatch string) (*watcher.Watcher, error)

InitializeWatcher initialize a watcher to check for modification on all files in the given path to watch

Types

type Config added in v0.3.3

type Config struct {
	ImpostersPath string      `yaml:"imposters_path"`
	Port          int         `yaml:"port"`
	Host          string      `yaml:"host"`
	CORS          ConfigCORS  `yaml:"cors"`
	Proxy         ConfigProxy `yaml:"proxy"`
	Secure        bool        `yaml:"secure"`
	Watcher       bool        `yaml:"watcher"`
}

Config representation of config file yaml

func NewConfig added in v0.4.0

func NewConfig(impostersPath, host string, port int, secure bool) (Config, error)

NewConfig initialize the config

func NewConfigFromFile added in v0.5.0

func NewConfigFromFile(cfgPath string) (Config, error)

NewConfigFromFile unmarshal content of config file to initialize a Config struct

func (*Config) ConfigureProxy added in v0.5.0

func (cfg *Config) ConfigureProxy(proxyMode ProxyMode, proxyURL string)

ConfigureProxy preparing the server with the proxy configuration that the user has indicated

type ConfigCORS added in v0.3.3

type ConfigCORS struct {
	Methods          []string `yaml:"methods"`
	Headers          []string `yaml:"headers"`
	Origins          []string `yaml:"origins"`
	ExposedHeaders   []string `yaml:"exposed_headers"`
	AllowCredentials bool     `yaml:"allow_credentials"`
}

ConfigCORS representation of section CORS of the yaml

type ConfigOpt added in v0.4.0

type ConfigOpt func(cfg *Config) error

ConfigOpt function to encapsulate optional parameters

type ConfigProxy added in v0.4.0

type ConfigProxy struct {
	Url  string    `yaml:"url"`
	Mode ProxyMode `yaml:"mode"`
}

ConfigProxy is a representation of section proxy of the yaml

type ProxyMode added in v0.4.0

type ProxyMode uint8

ProxyMode is enumeration of proxy server modes

const (
	// ProxyNone server is off
	ProxyNone ProxyMode = iota
	// ProxyMissing handle only missing requests are proxied
	ProxyMissing
	// ProxyAll all requests are proxied
	ProxyAll
)

func StringToProxyMode added in v0.4.0

func StringToProxyMode(t string) (ProxyMode, error)

StringToProxyMode convert string into a ProxyMode if not exists return a none mode and an error

func (ProxyMode) String added in v0.4.0

func (p ProxyMode) String() string

func (*ProxyMode) UnmarshalYAML added in v0.4.0

func (p *ProxyMode) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implementation of yaml.Unmarshaler interface

Directories

Path Synopsis
app
cmd
server

Jump to

Keyboard shortcuts

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