Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ type SpoofingConfig struct {
}

type SpoofingCallbacks struct {
RequestCallbacks map[string]func([]byte) *Spoof
ResponseCallbacks map[string]func([]byte) *Spoof
// Map of method names to callbacks, where the callback will receive the request bytes as only parameter
RequestCallbacks map[string]func([]byte) *Spoof
// Map of method names to callbacks, where the callback will receive the response bytes as 1st parameter,
// and original request bytes as 2nd parameter
ResponseCallbacks map[string]func([]byte, []byte) *Spoof
}

type Spoof struct {
Expand Down Expand Up @@ -304,7 +307,7 @@ func spoofResponse(config *SpoofingConfig, callbacks *SpoofingCallbacks, request
desiredMethodsToSpoof := make(map[string]*Spoof)
for method, spoofCallback := range callbacks.ResponseCallbacks {
if method == jsonRequest.Method {
spoofReq := spoofCallback(responseBytes)
spoofReq := spoofCallback(responseBytes, requestBytes)
if spoofReq != nil {
desiredMethodsToSpoof[jsonRequest.Method] = spoofReq
}
Expand Down