silgi 0.1.0-beta.2 → 0.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/handler.mjs +29 -2
- package/package.json +1 -1
package/dist/core/handler.mjs
CHANGED
|
@@ -376,7 +376,13 @@ location.reload();
|
|
|
376
376
|
ctx.__analyticsTrace = reqTrace;
|
|
377
377
|
ctx.trace = reqTrace.trace.bind(reqTrace);
|
|
378
378
|
}
|
|
379
|
-
if (route.passthrough) {
|
|
379
|
+
if (route.passthrough) {
|
|
380
|
+
if (collector && request.body && request.method !== "GET") try {
|
|
381
|
+
const cloned = request.clone();
|
|
382
|
+
const ct = cloned.headers.get("content-type");
|
|
383
|
+
if (ct && ct.includes("json")) rawInput = await cloned.json();
|
|
384
|
+
} catch {}
|
|
385
|
+
} else if (request.method === "GET") {
|
|
380
386
|
if (qMark !== -1) {
|
|
381
387
|
const searchStr = url.slice(qMark + 1);
|
|
382
388
|
const dataIdx = searchStr.indexOf("data=");
|
|
@@ -415,7 +421,28 @@ location.reload();
|
|
|
415
421
|
t0 = collector ? performance.now() : 0;
|
|
416
422
|
const pipelineResult = route.handler(ctx, rawInput, request.signal);
|
|
417
423
|
const output = pipelineResult instanceof Promise ? await pipelineResult : pipelineResult;
|
|
418
|
-
if (output instanceof Response)
|
|
424
|
+
if (output instanceof Response) {
|
|
425
|
+
if (hasHooks || collector) {
|
|
426
|
+
const durationMs = collector ? round(performance.now() - t0) : 0;
|
|
427
|
+
if (hasHooks) hooks.callHook("response", {
|
|
428
|
+
path: pathname,
|
|
429
|
+
output: null,
|
|
430
|
+
durationMs
|
|
431
|
+
});
|
|
432
|
+
if (collector) {
|
|
433
|
+
collector.record(pathname, durationMs);
|
|
434
|
+
if (accumulator) accumulator.addProcedure({
|
|
435
|
+
procedure: pathname,
|
|
436
|
+
durationMs,
|
|
437
|
+
status: output.status,
|
|
438
|
+
input: rawInput,
|
|
439
|
+
output: null,
|
|
440
|
+
spans: reqTrace?.spans ?? []
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return output;
|
|
445
|
+
}
|
|
419
446
|
if (output instanceof ReadableStream) {
|
|
420
447
|
if (collector) {
|
|
421
448
|
const durationMs = round(performance.now() - t0);
|
package/package.json
CHANGED