Documentation ¶
Index ¶
Constants ¶
const ( //URLKey represents url key URLKey = "URL" //CookieKey represents cookie header key CookieKey = "Cookie" //ContentTypeKey represents content type header key ContentTypeKey = "Content-Type" //MethodKey represents http method key MethodKey = "Method" //BodyKey represents http body key BodyKey = "Body" //DefaultRequestTemplate request template DefaultRequestTemplate = "%02d-req.json" //DefaultResponseTemplate response tempalte DefaultResponseTemplate = "%02d-resp.json" )
const (
//ServiceID represents hTTPEndpoint service id.
ServiceID = "http/endpoint"
)
Variables ¶
var HTTPRequestKeyProviders = make(map[string]HTTPRequestKeyProvider)
HTTPRequestKeyProviders represents key providers
Functions ¶
func StartRecorder ¶
StartRecorder starts HTTP recorded for supplied URLs
Types ¶
type AppendRequest ¶
type AppendRequest struct { Port int BaseDirectory string `` /* 164-byte string literal not displayed */ }
func (AppendRequest) AsHTTPServerTrips ¶
func (r AppendRequest) AsHTTPServerTrips(rotate bool, indexKeys []string) *HTTPServerTrips
AsHTTPServerTrips return a new HTTP trips.
func (AppendRequest) Validate ¶
func (r AppendRequest) Validate() error
Validate checks if request is valid.
type AppendResponse ¶
type AppendResponse struct {
Trips map[string]*HTTPResponses
}
ListenResponse represents HTTP endpoint listen response with indexed trips
type HTTPRequestKeyProvider ¶
HTTPRequestKeyProvider represents request key provider to extract a request field.
func HeaderProvider ¶
func HeaderProvider(header string) HTTPRequestKeyProvider
HeaderProvider return a header value for supplied source
type HTTPResponses ¶
type HTTPResponses struct { Request *bridge.HttpRequest Responses []*bridge.HttpResponse Index uint32 }
HTTPResponses represents HTTPResponses
type HTTPServerTrips ¶
type HTTPServerTrips struct { BaseDirectory string Rotate bool Trips map[string]*HTTPResponses IndexKeys []string Mutex *sync.Mutex }
HTTPServerTrips represents http trips
type ListenRequest ¶
type ListenRequest struct { Port int Rotate bool RequestTemplate string `description:"request file loading template, default: %02d-req.json"` ResponseTemplate string `description:"response file loading template, default: %02d-resp.json"` BaseDirectory string `` /* 164-byte string literal not displayed */ IndexKeys []string `description:"recorded requests matching keys, by default: Method,URL,Body,Cookie,Content-Type"` }
ListenRequest represent HTTP endpoint listen request
func (ListenRequest) AsHTTPServerTrips ¶
func (r ListenRequest) AsHTTPServerTrips() *HTTPServerTrips
AsHTTPServerTrips return a new HTTP trips.
func (*ListenRequest) Init ¶
func (r *ListenRequest) Init() error
func (ListenRequest) Validate ¶
func (r ListenRequest) Validate() error
Validate checks if request is valid.
type ListenResponse ¶
type ListenResponse struct {
Trips map[string]*HTTPResponses
}
ListenResponse represents HTTP endpoint listen response with indexed trips
type Server ¶
func StartServer ¶
func StartServer(port int, trips *HTTPServerTrips, reqTemplate, respTemplate string) (*Server, error)
StartServer starts http request, the server has ability to replay recorded HTTP trips with https://github.com/viant/toolbox/blob/master/bridge/http_bridge_recording_util.go#L82
func (*Server) Append ¶
func (s *Server) Append(trips *HTTPServerTrips)
type ShutdownRequest ¶
type ShutdownRequest struct {
Port int
}
ShutdownRequest represent http endpoint shutdown request