MCPcopy
hub / github.com/probelabs/goreplay / parseMessage

Function parseMessage

middleware/middleware.js:105–125  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

103
104
105function parseMessage(msg) {
106 try {
107 let payload = Buffer.from(msg, "hex");
108 let metaPos = payload.indexOf("\n");
109 let meta = payload.slice(0, metaPos);
110 let metaArr = meta.toString("ascii").split(" ");
111 let pType = metaArr[0];
112 let pID = metaArr[1];
113 let raw = payload.slice(metaPos + 1, payload.length);
114
115 return {
116 type: pType,
117 ID: pID,
118 rawMeta: meta,
119 meta: metaArr,
120 http: raw
121 }
122 } catch(e) {
123 fail(`Error while parsing incoming request: ${msg}`)
124 }
125}
126
127// Used to compare values from original and replayed responses
128// Accepts request id, regexp pattern for searching the compared value (should include capture group), and callback which returns both original and replayed matched value.

Callers 5

initFunction · 0.85
testBenchmarkFunction · 0.85
TEST_initFunction · 0.85
TEST_filterFunction · 0.85
TEST_parseMessageFunction · 0.85

Calls 1

failFunction · 0.85

Tested by

no test coverage detected