killgrave

package
v0.0.0-...-9069922 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachWatcher

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

func CloseWatcher(w *watcher.Watcher)

func InitializeWatcher

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

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

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

NewConfig initialize the config

func NewConfigFromFile

func NewConfigFromFile(cfgPath string) (Config, error)

NewConfigFromFile unmarshal content of config file to initialize a Config struct

func (*Config) ConfigureProxy

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

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

type ConfigCORS

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

type ConfigOpt func(cfg *Config) error

ConfigOpt function to encapsulate optional parameters

type ConfigProxy

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

ConfigProxy is a representation of section proxy of the yaml

type ProxyMode

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

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

func (p ProxyMode) String() string

func (*ProxyMode) UnmarshalYAML

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