Open fsyj-123 opened 1 year ago
the code of middleware is modeled after token_modifier.go
Overall it is asyncronious flow, where a lot of goroutines are involved, so hard to guarantee the order. But you can get inspiration on how JS middleware solves it https://github.com/buger/goreplay/tree/master/middleware
// Example of very basic way to compare if replayed traffic have no errors
gor.on("request", function(req) {
gor.on("response", req.ID, function(resp) {
gor.on("replay", req.ID, function(repl) {
if (gor.httpStatus(resp.http) != gor.httpStatus(repl.http)) {
// Note that STDERR is used for logging, and it actually will be send to `Gor` STDOUT.
// This trick is used because SDTIN and STDOUT already used for process communication.
// You can write logger that writes to files insead.
console.error(`${gor.httpPath(req.http)} STATUS NOT MATCH: 'Expected ${gor.httpStatus(resp.http)}' got '${gor.httpStatus(repl.http)}'`)
}
return repl;
})
return resp;
})
return req
})
i am developing a middleware, how can i recive payload in order of 1、2、3 The above image shows that the order I received is 1, 3, and 2,but i want in order of 1、2、3 below is my command to replay request
./gor --input-file requests_0.gor --input-raw-track-response --middleware "./apps/main" --output-http "http://localhost:85" --output-http-track-response