Documentation ¶
Index ¶
- Constants
- Variables
- func GetAllHandlers(hoverfly *Hoverfly) []handlers.AdminHandler
- func GetDefaultHoverflyHTTPClient(tlsVerification bool, upstreamProxy string) *http.Client
- func GetRandomName(n int) []byte
- func NewProxy(hoverfly *Hoverfly) *goproxy.ProxyHttpServer
- func NewWebserverProxy(hoverfly *Hoverfly) *goproxy.ProxyHttpServer
- type ActionType
- type ActionTypeHooks
- type AdminApi
- type Client
- type Configuration
- type Entry
- type Hook
- type Hoverfly
- func (this Hoverfly) ApplyMiddleware(pair models.RequestResponsePair) (models.RequestResponsePair, error)
- func (hf Hoverfly) DeleteRequestCache() error
- func (hf *Hoverfly) DeleteResponseDelays()
- func (this *Hoverfly) DeleteSimulation()
- func (hf *Hoverfly) DoRequest(request *http.Request) (*http.Response, error)
- func (this Hoverfly) GetDestination() string
- func (this Hoverfly) GetMetadataCache() cache.Cache
- func (hf Hoverfly) GetMiddleware() (string, string, string)
- func (this Hoverfly) GetMode() string
- func (hf Hoverfly) GetRecords() ([]v1.RequestResponsePairView, error)
- func (hf Hoverfly) GetRequestCacheCount() (int, error)
- func (hf *Hoverfly) GetResponse(requestDetails models.RequestDetails) (*models.ResponseDetails, *matching.MatchingError)
- func (hf *Hoverfly) GetResponseDelays() v1.ResponseDelayPayloadView
- func (hf Hoverfly) GetSimulation() (v2.SimulationView, error)
- func (hf Hoverfly) GetStats() metrics.Stats
- func (this Hoverfly) GetUpstreamProxy() string
- func (this 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) ImportRequestResponsePairViews(pairViews []interfaces.RequestResponsePair) error
- func (this Hoverfly) IsMiddlewareSet() bool
- func (this *Hoverfly) PutSimulation(simulationView v2.SimulationView) error
- 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 (this *Hoverfly) SetMode(mode string) error
- func (hf *Hoverfly) SetResponseDelays(payloadView v1.ResponseDelayPayloadView) error
- func (hf *Hoverfly) StartProxy() error
- func (hf *Hoverfly) StopProxy()
- type Middleware
- func (this *Middleware) DeleteScripts(path string) error
- func (this *Middleware) Execute(pair models.RequestResponsePair) (models.RequestResponsePair, error)
- func (this Middleware) GetScript() (string, error)
- func (this Middleware) IsSet() bool
- func (this *Middleware) SetBinary(binary string) error
- func (this *Middleware) SetRemote(remoteUrl string) error
- func (this *Middleware) SetScript(scriptContent string) error
- type StoppableListener
Constants ¶
const ( HoverflyAuthEnabledEV = "HoverflyAuthEnabled" HoverflySecretEV = "HoverflySecret" HoverflyTokenExpirationEV = "HoverflyTokenExpiration" HoverflyAdminPortEV = "AdminPort" HoverflyProxyPortEV = "ProxyPort" HoverflyDBEV = "HoverflyDB" HoverflyMiddlewareEV = "HoverflyMiddleware" HoverflyTLSVerification = "HoverflyTlsVerification" HoverflyAdminUsernameEV = "HoverflyAdmin" HoverflyAdminPasswordEV = "HoverflyAdminPass" HoverflyImportRecordsEV = "HoverflyImport" HoverflyUpstreamProxyPortEV = "UpstreamProxy" )
Environment variables
const ActionTypeConfigurationChanged = "configurationChanged"
ActionTypeConfigurationChanged - default action name for identifying configuration changes
const ActionTypeRequestCaptured = "requestCaptured"
ActionTypeRequestCaptured - default action type name for identifying
const ActionTypeWipeDB = "wipeDatabase"
ActionTypeWipeDB - default action type for wiping database
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 DefaultPort = "8500"
DefaultPort - default proxy port
const URL string = `` /* 321-byte string literal not displayed */
URL is regexp to match http urls
Variables ¶
var TestDB *bolt.DB
TestDB - holds connection to database during tests
Functions ¶
func GetAllHandlers ¶ added in v0.9.0
func GetAllHandlers(hoverfly *Hoverfly) []handlers.AdminHandler
func GetDefaultHoverflyHTTPClient ¶ added in v0.9.0
func GetRandomName ¶
GetRandomName - provides random name for buckets. Each test case gets it's own bucket
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 ActionType ¶
type ActionType string
ActionType - action type can be things such as "RequestCaptured", "GotResponse" - anything
type ActionTypeHooks ¶
type ActionTypeHooks map[ActionType][]Hook
ActionTypeHooks type for storing the hooks
func (ActionTypeHooks) Fire ¶
func (hooks ActionTypeHooks) Fire(ac ActionType, entry *Entry) error
Fire all the hooks for the passed ActionType
type AdminApi ¶ added in v0.9.0
type AdminApi struct{}
func (*AdminApi) StartAdminInterface ¶ added in v0.9.0
StartAdminInterface - starts admin interface web server
type Configuration ¶
type Configuration struct { AdminPort string ProxyPort string Mode string Destination string Middleware Middleware DatabasePath string Webserver bool TLSVerification bool UpstreamProxy string Verbose bool Development bool SecretKey []byte JWTExpirationDelta int AuthEnabled bool 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 Entry ¶
type Entry struct { // Contains encoded data Data []byte // Time at which the action entry was fired Time time.Time ActionType ActionType // Message, can carry additional information Message string }
Entry - holds information about action, based on action type - other clients will be able to decode the data field.
type Hook ¶
type Hook interface { ActionTypes() []ActionType Fire(*Entry) error }
Hook - an interface to add dynamic hooks to extend functionality
type Hoverfly ¶
type Hoverfly struct { RequestCache cache.Cache RequestMatcher matching.RequestMatcher MetadataCache cache.Cache Authentication authBackend.Authentication HTTP *http.Client Cfg *Configuration Counter *metrics.CounterByMode ResponseDelays models.ResponseDelays Proxy *goproxy.ProxyHttpServer SL *StoppableListener Simulation *models.Simulation // 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, metadataCache cache.Cache, authentication authBackend.Authentication) *Hoverfly
GetNewHoverfly returns a configured ProxyHttpServer and DBClient
func (Hoverfly) ApplyMiddleware ¶ added in v0.10.0
func (this Hoverfly) ApplyMiddleware(pair models.RequestResponsePair) (models.RequestResponsePair, error)
func (Hoverfly) DeleteRequestCache ¶ added in v0.9.0
func (*Hoverfly) DeleteResponseDelays ¶ added in v0.9.0
func (hf *Hoverfly) DeleteResponseDelays()
func (*Hoverfly) DeleteSimulation ¶ added in v0.9.0
func (this *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) GetDestination ¶ added in v0.9.0
func (Hoverfly) GetMetadataCache ¶ added in v0.9.0
func (Hoverfly) GetMiddleware ¶ added in v0.9.0
func (Hoverfly) GetRecords ¶ added in v0.9.0
func (hf Hoverfly) GetRecords() ([]v1.RequestResponsePairView, error)
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, *matching.MatchingError)
GetResponse returns stored response from cache
func (*Hoverfly) GetResponseDelays ¶ added in v0.9.0
func (hf *Hoverfly) GetResponseDelays() v1.ResponseDelayPayloadView
func (Hoverfly) GetSimulation ¶ added in v0.9.0
func (hf Hoverfly) GetSimulation() (v2.SimulationView, 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) ImportRequestResponsePairViews ¶ added in v0.8.1
func (hf *Hoverfly) ImportRequestResponsePairViews(pairViews []interfaces.RequestResponsePair) error
ImportRequestResponsePairViews - a function to save given pairs into the database.
func (Hoverfly) IsMiddlewareSet ¶ added in v0.10.0
func (*Hoverfly) PutSimulation ¶ added in v0.9.0
func (this *Hoverfly) PutSimulation(simulationView v2.SimulationView) error
func (*Hoverfly) Save ¶ added in v0.10.0
func (hf *Hoverfly) Save(request *models.RequestDetails, response *models.ResponseDetails) 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) SetResponseDelays ¶ added in v0.9.0
func (hf *Hoverfly) SetResponseDelays(payloadView v1.ResponseDelayPayloadView) error
func (*Hoverfly) StartProxy ¶
StartProxy - starts proxy with current configuration, this method is non blocking.
type Middleware ¶ added in v0.10.0
func ConvertToNewMiddleware ¶ added in v0.10.0
func ConvertToNewMiddleware(middleware string) (*Middleware, error)
func (*Middleware) DeleteScripts ¶ added in v0.10.0
func (this *Middleware) DeleteScripts(path string) error
func (*Middleware) Execute ¶ added in v0.10.0
func (this *Middleware) Execute(pair models.RequestResponsePair) (models.RequestResponsePair, error)
func (Middleware) GetScript ¶ added in v0.10.0
func (this Middleware) GetScript() (string, error)
func (Middleware) IsSet ¶ added in v0.10.0
func (this Middleware) IsSet() bool
func (*Middleware) SetBinary ¶ added in v0.10.0
func (this *Middleware) SetBinary(binary string) error
func (*Middleware) SetRemote ¶ added in v0.10.0
func (this *Middleware) SetRemote(remoteUrl string) error
func (*Middleware) SetScript ¶ added in v0.10.0
func (this *Middleware) SetScript(scriptContent string) error
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