Documentation ¶
Index ¶
- func CopyWithBufferPool(source io.Reader, destination io.Writer, pool httputil.BufferPool) (int64, error)
- func HttpFileRecorder(directory string, printStdOut bool) func(request *http.Request, response *http.Response)
- func NewBytesBufferPool(poolSize, bufferSize int) httputil.BufferPool
- func NewProxyHandler(proxyConfig *HttpBridgeProxyConfig, route *HttpBridgeProxyRoute) (http.Handler, error)
- func NewProxyRecordingHandler(proxyConfig *HttpBridgeProxyConfig, route *HttpBridgeProxyRoute) (http.Handler, error)
- func ReaderAsText(reader io.Reader) string
- type HttpBridge
- type HttpBridgeConfig
- type HttpBridgeEndpointConfig
- type HttpBridgeProxyConfig
- type HttpBridgeProxyHandlerFactory
- type HttpBridgeProxyRoute
- type HttpRequest
- type HttpResponse
- type HttpTrip
- type ListeningTripHandler
- type RecordedHttpTrip
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyWithBufferPool ¶
func CopyWithBufferPool(source io.Reader, destination io.Writer, pool httputil.BufferPool) (int64, error)
CopyBuffer copies bytes from passed in source to destination with provided pool
func HttpFileRecorder ¶
func HttpFileRecorder(directory string, printStdOut bool) func(request *http.Request, response *http.Response)
HttpFileRecorder returns http route listener that will record request response to the passed in directory
func NewBytesBufferPool ¶
func NewBytesBufferPool(poolSize, bufferSize int) httputil.BufferPool
NewBytesBufferPool returns new httputil.BufferPool pool.
func NewProxyHandler ¶
func NewProxyHandler(proxyConfig *HttpBridgeProxyConfig, route *HttpBridgeProxyRoute) (http.Handler, error)
NewProxyHandler creates a new proxy handler
func NewProxyRecordingHandler ¶
func NewProxyRecordingHandler(proxyConfig *HttpBridgeProxyConfig, route *HttpBridgeProxyRoute) (http.Handler, error)
func ReaderAsText ¶
Types ¶
type HttpBridge ¶
type HttpBridge struct { Config *HttpBridgeConfig Server *http.Server Handlers map[string]http.Handler }
HttpBridge represents http bridge
func NewHttpBridge ¶
func NewHttpBridge(config *HttpBridgeConfig, factory HttpBridgeProxyHandlerFactory) (*HttpBridge, error)
NewHttpBridge creates a new instance of NewHttpBridge
func StartRecordingBridge ¶
func StartRecordingBridge(port string, outputDirectory string, routes ...*HttpBridgeProxyRoute) (*HttpBridge, error)
StartRecordingBridge start recording bridge proxy
func (*HttpBridge) ListenAndServe ¶
func (r *HttpBridge) ListenAndServe() error
ListenAndServe start http endpoint
func (*HttpBridge) ListenAndServeTLS ¶
func (r *HttpBridge) ListenAndServeTLS(certFile, keyFile string) error
ListenAndServe start http endpoint on secure port
type HttpBridgeConfig ¶
type HttpBridgeConfig struct { Endpoint *HttpBridgeEndpointConfig Proxy *HttpBridgeProxyConfig Routes []*HttpBridgeProxyRoute }
HttpBridgeConfig represents HttpBridgeConfig config
type HttpBridgeEndpointConfig ¶
type HttpBridgeEndpointConfig struct { Port string ReadTimeoutMs int WriteTimeoutMs int MaxHeaderBytes int }
HttpBridgeConfig represent http bridge config
type HttpBridgeProxyConfig ¶
type HttpBridgeProxyConfig struct { MaxIdleConnections int RequestTimeoutMs int KeepAliveTimeMs int TLSHandshakeTimeoutMs int BufferPoolSize int BufferSize int }
HttpBridgeProxyConfig represent proxy config
type HttpBridgeProxyHandlerFactory ¶
type HttpBridgeProxyHandlerFactory func(proxyConfig *HttpBridgeProxyConfig, route *HttpBridgeProxyRoute) (http.Handler, error)
ProxyHandlerFactory proxy handler factory
type HttpBridgeProxyRoute ¶
type HttpBridgeProxyRoute struct { Pattern string TargetURL *url.URL ResponseModifier func(*http.Response) error Listener func(request *http.Request, response *http.Response) }
HttpBridgeProxyRoute represent http proxy route
type HttpRequest ¶
type HttpRequest struct { Method string `json:",omitempty"` URL string `json:",omitempty"` Header http.Header `json:",omitempty"` Body string `json:",omitempty"` }
HttpRequest represents JSON serializable http request
func NewHTTPRequest ¶
func NewHTTPRequest(method, url, body string, header http.Header) *HttpRequest
NewHTTPRequest create a new instance of http request
type HttpResponse ¶
type HttpResponse struct { Code int Header http.Header `json:",omitempty"` Body string `json:",omitempty"` }
HttpResponse represents JSON serializable http response
type HttpTrip ¶
HTTPTrip represents recorded round trip.
func (*HttpTrip) CloseNotify ¶
func (*HttpTrip) WriteHeader ¶
type ListeningTripHandler ¶
type ListeningTripHandler struct {
// contains filtered or unexported fields
}
ListeningTripHandler represents endpoint recording handler
func AsListeningTripHandler ¶
func AsListeningTripHandler(handler http.Handler) *ListeningTripHandler
func NewListeningHandler ¶
func (*ListeningTripHandler) Notify ¶
func (h *ListeningTripHandler) Notify(roundTrip *HttpTrip)
func (ListeningTripHandler) ServeHTTP ¶
func (h ListeningTripHandler) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)
type RecordedHttpTrip ¶
type RecordedHttpTrip struct { Request *HttpRequest Response *HttpResponse }
RecordedHttpTrip represents a recorded http trip
func ReadRecordedHttpTrips ¶
func ReadRecordedHttpTrips(directory string) ([]*RecordedHttpTrip, error)
ReadRecordedHttpTrips scans provided directory for bridge.HttpRequest-%v.json and bridge.HttpResponse-%v.json pairs