Documentation ¶
Index ¶
- Constants
- Variables
- func GetDefaultHoverflyHTTPClient(tlsVerification bool, upstreamProxy string) *http.Client
- func GetHttpClient(hf *Hoverfly, host string) (*http.Client, error)
- func NewProxy(hoverfly *Hoverfly) *goproxy.ProxyHttpServer
- func NewWebserverProxy(hoverfly *Hoverfly) *goproxy.ProxyHttpServer
- type AdminApi
- type Configuration
- type Fields
- type Hoverfly
- func (hf *Hoverfly) AddDiff(requestView v2.SimpleRequestDefinitionView, diffReport v2.DiffReport)
- func (hf *Hoverfly) ApplyMiddleware(pair models.RequestResponsePair) (models.RequestResponsePair, error)
- func (hf *Hoverfly) ClearDiff()
- func (hf *Hoverfly) ClearState()
- func (hf *Hoverfly) DeletePACFile()
- func (hf *Hoverfly) DeleteResponseDelays()
- func (hf *Hoverfly) DeleteResponseDelaysLogNormal()
- func (hf *Hoverfly) DeleteSimulation()
- func (hf *Hoverfly) DoRequest(request *http.Request) (*http.Response, error)
- func (hf *Hoverfly) FlushCache() error
- func (hf *Hoverfly) GetCORS() v2.CORSView
- func (hf *Hoverfly) GetCache() (v2.CacheView, error)
- func (hf *Hoverfly) GetDestination() string
- func (hf *Hoverfly) GetDiff() map[v2.SimpleRequestDefinitionView][]v2.DiffReport
- func (hf *Hoverfly) GetFilteredSimulation(urlPattern string) (v2.SimulationViewV5, error)
- func (hf *Hoverfly) GetMiddleware() (string, string, string)
- func (hf *Hoverfly) GetMode() v2.ModeView
- func (hf *Hoverfly) GetPACFile() []byte
- func (hf *Hoverfly) GetRequestCacheCount() (int, error)
- func (hf *Hoverfly) GetResponse(requestDetails models.RequestDetails) (*models.ResponseDetails, *errors.HoverflyError)
- func (hf *Hoverfly) GetSimulation() (v2.SimulationViewV5, error)
- func (hf *Hoverfly) GetState() map[string]string
- func (hf *Hoverfly) GetStats() metrics.Stats
- func (hf *Hoverfly) GetUpstreamProxy() string
- func (hf *Hoverfly) GetVersion() string
- func (hf *Hoverfly) Import(uri string) error
- func (hf *Hoverfly) ImportFromDisk(path string) error
- func (hf *Hoverfly) ImportFromURL(url string) error
- func (hf *Hoverfly) IsMiddlewareSet() bool
- func (hf *Hoverfly) IsWebServer() bool
- func (hf *Hoverfly) PatchState(toPatch map[string]string)
- func (hf *Hoverfly) PutSimulation(simulationView v2.SimulationViewV5) v2.SimulationImportResult
- func (hf *Hoverfly) ReplaceSimulation(simulationView v2.SimulationViewV5) v2.SimulationImportResult
- func (hf *Hoverfly) Save(request *models.RequestDetails, response *models.ResponseDetails, ...) error
- func (hf *Hoverfly) SetDestination(destination string) (err error)
- func (hf *Hoverfly) SetMiddleware(binary, script, remote string) error
- func (hf *Hoverfly) SetMode(mode string) error
- func (hf *Hoverfly) SetModeWithArguments(modeView v2.ModeView) error
- func (hf *Hoverfly) SetPACFile(pacFile []byte)
- func (hf *Hoverfly) SetResponseDelays(payloadView v1.ResponseDelayPayloadView) error
- func (hf *Hoverfly) SetResponseDelaysLogNormal(payloadView v1.ResponseDelayLogNormalPayloadView) error
- func (hf *Hoverfly) SetState(state map[string]string)
- func (hf *Hoverfly) StartProxy() error
- func (hf *Hoverfly) StopProxy()
- type StoppableListener
- type StoreLogsHook
Constants ¶
const ( // TODO Should use naming convention for environment variables HoverflyAuthEnabledEV = "HoverflyAuthEnabled" HoverflySecretEV = "HoverflySecret" HoverflyTokenExpirationEV = "HoverflyTokenExpiration" HoverflyAdminPortEV = "AdminPort" HoverflyProxyPortEV = "ProxyPort" HoverflyDBEV = "HoverflyDB" HoverflyMiddlewareEV = "HoverflyMiddleware" HoverflyTLSVerification = "HoverflyTlsVerification" HoverflyAdminUsernameEV = "HoverflyAdmin" HoverflyAdminPasswordEV = "HoverflyAdminPass" HoverflyImportRecordsEV = "HoverflyImport" HoverflyUpstreamProxyPortEV = "UpstreamProxy" HoverflySkipImportCheckEV = "SKIP_IMPORT_CHECK" )
Environment variables
const DefaultAdminPort = "8888"
DefaultAdminPort - default admin interface port
const DefaultDatabasePath = "requests.db"
DefaultDatabasePath - default database name that will be created or used by Hoverfly
const DefaultJWTExpirationDelta = 1 * 24 * 60 * 60
DefaultJWTExpirationDelta - default token expiration if environment variable is no provided
const DefaultListenOnHost = "127.0.0.1"
const DefaultPort = "8500"
DefaultPort - default proxy port
Variables ¶
var ProxyAuthorizationHeader string
Functions ¶
func GetDefaultHoverflyHTTPClient ¶ added in v0.9.0
func GetHttpClient ¶ added in v0.17.4
func NewProxy ¶
func NewProxy(hoverfly *Hoverfly) *goproxy.ProxyHttpServer
Creates goproxy.ProxyHttpServer and configures it to be used as a proxy for Hoverfly goproxy is given handlers that use the Hoverfly request processing
func NewWebserverProxy ¶
func NewWebserverProxy(hoverfly *Hoverfly) *goproxy.ProxyHttpServer
Creates goproxy.ProxyHttpServer and configures it to be used as a webserver for Hoverfly goproxy is given a non proxy handler that uses the Hoverfly request processing
Types ¶
type AdminApi ¶ added in v0.9.0
type AdminApi struct{}
func (*AdminApi) StartAdminInterface ¶ added in v0.9.0
Starts the Admin API on a new HTTP port. Port is chosen by hoverfly.Cfg.AdminPort.
type Configuration ¶
type Configuration struct { AdminPort string ProxyPort string ListenOnHost string Mode string Destination string Middleware middleware.Middleware DatabasePath string Webserver bool TLSVerification bool UpstreamProxy string PACFile []byte Verbose bool DisableCache bool CacheSize int SecretKey []byte JWTExpirationDelta int AuthEnabled bool ProxyAuthorizationHeader string PlainHttpTunneling bool CORS cors.Configs NoImportCheck bool ClientAuthenticationDestination string ClientAuthenticationClientCert string ClientAuthenticationClientKey string ClientAuthenticationCACert string ResponsesBodyFilesPath string ResponsesBodyFilesAllowedOrigins []string ProxyControlWG sync.WaitGroup // contains filtered or unexported fields }
Configuration - initial structure of configuration
func InitSettings ¶
func InitSettings() *Configuration
InitSettings gets and returns initial configuration from env variables or sets defaults
func (*Configuration) GetMode ¶
func (c *Configuration) GetMode() string
GetMode - provides safe way to get current mode
func (*Configuration) SetMode ¶
func (c *Configuration) SetMode(mode string)
SetMode - provides safe way to set new mode
func (*Configuration) SetUpstreamProxy ¶ added in v0.10.1
func (c *Configuration) SetUpstreamProxy(upstreamProxy string)
type Hoverfly ¶
type Hoverfly struct { CacheMatcher matching.CacheMatcher Authentication backends.Authentication HTTP *http.Client Cfg *Configuration Counter *metrics.CounterByMode Proxy *goproxy.ProxyHttpServer SL *StoppableListener Simulation *models.Simulation StoreLogsHook *StoreLogsHook Journal *journal.Journal // contains filtered or unexported fields }
Hoverfly provides access to hoverfly - updating/starting/stopping proxy, http client and configuration, cache access
func GetNewHoverfly ¶
func GetNewHoverfly(cfg *Configuration, requestCache cache.FastCache, authentication backends.Authentication) *Hoverfly
GetNewHoverfly returns a configured ProxyHttpServer and DBClient
func NewHoverfly ¶ added in v0.11.2
func NewHoverfly() *Hoverfly
func NewHoverflyWithConfiguration ¶ added in v0.11.0
func NewHoverflyWithConfiguration(cfg *Configuration) *Hoverfly
func (*Hoverfly) AddDiff ¶ added in v0.16.0
func (hf *Hoverfly) AddDiff(requestView v2.SimpleRequestDefinitionView, diffReport v2.DiffReport)
func (*Hoverfly) ApplyMiddleware ¶ added in v0.10.0
func (hf *Hoverfly) ApplyMiddleware(pair models.RequestResponsePair) (models.RequestResponsePair, error)
func (*Hoverfly) ClearState ¶ added in v0.14.0
func (hf *Hoverfly) ClearState()
func (*Hoverfly) DeletePACFile ¶ added in v0.17.4
func (hf *Hoverfly) DeletePACFile()
func (*Hoverfly) DeleteResponseDelays ¶ added in v0.9.0
func (hf *Hoverfly) DeleteResponseDelays()
func (*Hoverfly) DeleteResponseDelaysLogNormal ¶ added in v1.0.0
func (hf *Hoverfly) DeleteResponseDelaysLogNormal()
func (*Hoverfly) DeleteSimulation ¶ added in v0.9.0
func (hf *Hoverfly) DeleteSimulation()
func (*Hoverfly) DoRequest ¶ added in v0.10.0
DoRequest - performs request and returns response that should be returned to client and error
func (*Hoverfly) FlushCache ¶ added in v0.11.0
func (*Hoverfly) GetDestination ¶ added in v0.9.0
func (*Hoverfly) GetDiff ¶ added in v0.16.0
func (hf *Hoverfly) GetDiff() map[v2.SimpleRequestDefinitionView][]v2.DiffReport
func (*Hoverfly) GetFilteredSimulation ¶ added in v0.15.1
func (hf *Hoverfly) GetFilteredSimulation(urlPattern string) (v2.SimulationViewV5, error)
func (*Hoverfly) GetMiddleware ¶ added in v0.9.0
func (*Hoverfly) GetPACFile ¶ added in v0.17.4
func (*Hoverfly) GetRequestCacheCount ¶ added in v0.9.0
func (*Hoverfly) GetResponse ¶ added in v0.10.0
func (hf *Hoverfly) GetResponse(requestDetails models.RequestDetails) (*models.ResponseDetails, *errors.HoverflyError)
GetResponse returns stored response from cache
func (*Hoverfly) GetSimulation ¶ added in v0.9.0
func (hf *Hoverfly) GetSimulation() (v2.SimulationViewV5, error)
func (*Hoverfly) GetUpstreamProxy ¶ added in v0.10.1
func (*Hoverfly) GetVersion ¶ added in v0.10.1
func (*Hoverfly) Import ¶
Import is a function that based on input decides whether it is a local resource or whether it should fetch it from remote server. It then imports given payload into the database or returns an error
func (*Hoverfly) ImportFromDisk ¶
ImportFromDisk - takes one string value and tries to open a file, then parse it into recordedRequests structure (which is default format in which Hoverfly exports captured requests) and imports those requests into the database
func (*Hoverfly) ImportFromURL ¶
ImportFromURL - takes one string value and tries connect to a remote server, then parse response body into recordedRequests structure (which is default format in which Hoverfly exports captured requests) and imports those requests into the database
func (*Hoverfly) IsMiddlewareSet ¶ added in v0.10.0
func (*Hoverfly) IsWebServer ¶ added in v0.15.0
func (*Hoverfly) PatchState ¶ added in v0.14.0
func (*Hoverfly) PutSimulation ¶ added in v0.9.0
func (hf *Hoverfly) PutSimulation(simulationView v2.SimulationViewV5) v2.SimulationImportResult
func (*Hoverfly) ReplaceSimulation ¶ added in v1.3.0
func (hf *Hoverfly) ReplaceSimulation(simulationView v2.SimulationViewV5) v2.SimulationImportResult
func (*Hoverfly) Save ¶ added in v0.10.0
func (hf *Hoverfly) Save(request *models.RequestDetails, response *models.ResponseDetails, modeArgs *modes.ModeArguments) error
save gets request fingerprint, extracts request body, status code and headers, then saves it to cache
func (*Hoverfly) SetDestination ¶ added in v0.9.0
UpdateDestination - updates proxy with new destination regexp
func (*Hoverfly) SetMiddleware ¶ added in v0.8.0
func (*Hoverfly) SetModeWithArguments ¶ added in v0.11.0
func (*Hoverfly) SetPACFile ¶ added in v0.17.4
func (*Hoverfly) SetResponseDelays ¶ added in v0.9.0
func (hf *Hoverfly) SetResponseDelays(payloadView v1.ResponseDelayPayloadView) error
func (*Hoverfly) SetResponseDelaysLogNormal ¶ added in v1.0.0
func (hf *Hoverfly) SetResponseDelaysLogNormal(payloadView v1.ResponseDelayLogNormalPayloadView) error
func (*Hoverfly) StartProxy ¶
StartProxy - starts proxy with current configuration, this method is non blocking.
type StoppableListener ¶
type StoppableListener struct { *net.TCPListener // contains filtered or unexported fields }
StoppableListener - wrapper for tcp listener that can stop
func NewStoppableListener ¶
func NewStoppableListener(l net.Listener) (*StoppableListener, error)
NewStoppableListener returns new StoppableListener listener
type StoreLogsHook ¶ added in v0.11.0
func NewStoreLogsHook ¶ added in v0.11.0
func NewStoreLogsHook() *StoreLogsHook
func (*StoreLogsHook) Fire ¶ added in v0.11.0
func (hook *StoreLogsHook) Fire(entry *logrus.Entry) error
func (StoreLogsHook) Levels ¶ added in v0.11.0
func (hook StoreLogsHook) Levels() []logrus.Level