Skip to content
Merged
Changes from 1 commit
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
13 changes: 12 additions & 1 deletion src/middleware/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ function setKoaResponse(ctx, response) {
}
}

// Save response body of the primary route
ctx.resBody = Buffer.isBuffer(response.body)
? response.body.toString()
: response.body

for (const key in response.headers) {
const value = response.headers[key]
switch (key.toLowerCase()) {
Expand Down Expand Up @@ -488,6 +493,11 @@ function sendRequest(ctx, route, options) {
}
}

if (route.primary) {
// Save request body of the primary route
ctx.reqBody = Buffer.isBuffer(ctx.body) ? ctx.body.toString() : ctx.body
}

if (response instanceof Error) {
orchestration.error = {
message: response.message,
Expand Down Expand Up @@ -657,7 +667,8 @@ function sendKafkaRequest(ctx, route) {
method: ctx.request.method,
path: ctx.request.url,
headers: ctx.request.headers,
body: ctx.body && ctx.body.toString()
requestBody: ctx.reqBody ?? '',
responseBody: ctx.resBody ?? ''
}

return producer
Expand Down