Documentation ¶
Index ¶
- Variables
- func MatchRequestFilter(req *http.Request, expr search.Expression) (bool, error)
- func MatchRequestScope(req *http.Request, s *scope.Scope) (bool, error)
- func MatchResponseFilter(res *http.Response, expr search.Expression) (bool, error)
- func ShouldInterceptResponseFromContext(ctx context.Context) (bool, bool)
- func WithInterceptResponse(ctx context.Context, value bool) context.Context
- type Config
- type Item
- type Request
- type RequestIDs
- type Response
- type Service
- func (svc *Service) CancelRequest(reqID ulid.ULID) error
- func (svc *Service) CancelResponse(reqID ulid.ULID) error
- func (svc *Service) ClearRequests()
- func (svc *Service) ClearResponses()
- func (svc *Service) InterceptRequest(ctx context.Context, req *http.Request) (*http.Request, error)
- func (svc *Service) InterceptResponse(ctx context.Context, res *http.Response) (*http.Response, error)
- func (svc *Service) ItemByID(id ulid.ULID) (Item, error)
- func (svc *Service) Items() []Item
- func (svc *Service) ModifyRequest(reqID ulid.ULID, modReq *http.Request, modifyResponse *bool) error
- func (svc *Service) ModifyResponse(reqID ulid.ULID, modRes *http.Response) error
- func (svc *Service) RequestModifier(next proxy.RequestModifyFunc) proxy.RequestModifyFunc
- func (svc *Service) ResponseModifier(next proxy.ResponseModifyFunc) proxy.ResponseModifyFunc
- func (svc *Service) UpdateSettings(settings Settings)
- type Settings
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MatchRequestFilter ¶
MatchRequestFilter returns true if an HTTP request matches the request filter expression.
func MatchResponseFilter ¶
MatchResponseFilter returns true if an HTTP response matches the response filter expression.
Types ¶
type Config ¶
type Config struct { Logger log.Logger RequestsEnabled bool ResponsesEnabled bool RequestFilter search.Expression ResponseFilter search.Expression }
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents a server received HTTP request, alongside a channel for sending a modified version of it to the routine that's awaiting it. Also contains a channel for receiving a cancellation signal.
type RequestIDs ¶
RequestIDs implements sort.Interface.
func (RequestIDs) Len ¶
func (ids RequestIDs) Len() int
func (RequestIDs) Less ¶
func (ids RequestIDs) Less(i, j int) bool
func (RequestIDs) Swap ¶
func (ids RequestIDs) Swap(i, j int)
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response represents an HTTP response from a proxied request, alongside a channel for sending a modified version of it to the routine that's awaiting it. Also contains a channel for receiving a cancellation signal.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CancelRequest ¶
CancelRequest ensures an intercepted request is dropped.
func (*Service) CancelResponse ¶
CancelResponse ensures an intercepted response is dropped.
func (*Service) ClearRequests ¶
func (svc *Service) ClearRequests()
func (*Service) ClearResponses ¶
func (svc *Service) ClearResponses()
func (*Service) InterceptRequest ¶
InterceptRequest adds an HTTP request to an array of pending intercepted requests, alongside channels used for sending a cancellation signal and receiving a modified request. It's safe for concurrent use.
func (*Service) InterceptResponse ¶
func (svc *Service) InterceptResponse(ctx context.Context, res *http.Response) (*http.Response, error)
InterceptResponse adds an HTTP response to an array of pending intercepted responses, alongside channels used for sending a cancellation signal and receiving a modified response. It's safe for concurrent use.
func (*Service) ItemByID ¶
ItemByID returns an intercepted item (request and possible response) by ID. It's safe for concurrent use.
func (*Service) Items ¶
Items returns a list of pending items (requests and responses). It's safe for concurrent use.
func (*Service) ModifyRequest ¶
func (svc *Service) ModifyRequest(reqID ulid.ULID, modReq *http.Request, modifyResponse *bool) error
ModifyRequest sends a modified HTTP request to the related channel, or returns ErrRequestDone when the request was cancelled. It's safe for concurrent use.
func (*Service) ModifyResponse ¶
ModifyResponse sends a modified HTTP response to the related channel, or returns ErrRequestDone when the related request was cancelled. It's safe for concurrent use.
func (*Service) RequestModifier ¶
func (svc *Service) RequestModifier(next proxy.RequestModifyFunc) proxy.RequestModifyFunc
RequestModifier is a proxy.RequestModifyMiddleware for intercepting HTTP requests.
func (*Service) ResponseModifier ¶
func (svc *Service) ResponseModifier(next proxy.ResponseModifyFunc) proxy.ResponseModifyFunc
ResponseModifier is a proxy.ResponseModifyMiddleware for intercepting HTTP responses.
func (*Service) UpdateSettings ¶
type Settings ¶
type Settings struct { RequestsEnabled bool ResponsesEnabled bool RequestFilter search.Expression ResponseFilter search.Expression }