Skip to content

Commit

Permalink
fix trace message
Browse files Browse the repository at this point in the history
  • Loading branch information
gimmyxd committed Nov 22, 2024
1 parent 301afe3 commit bb65ece
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/util/connect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DescMessage } from "@bufbuild/protobuf";
import {
Code,
ConnectError,
Expand All @@ -16,15 +17,25 @@ import {
import { log } from "../log";

export const setHeader = (
req: UnaryRequest | StreamRequest,
req:
| UnaryRequest<DescMessage, DescMessage>
| StreamRequest<DescMessage, DescMessage>,
key: string,
value: string,
) => {
req.header.get(key) === null && req.header.set(key, value);
};

export const traceMessage: Interceptor = (next) => async (req) => {
log(JSON.stringify(req));
log(
JSON.stringify({
message: req.message,
method: req.method.toString(),
requestMethod: req.requestMethod.toString(),
service: req.service.toString(),
url: req.url.toString(),
}),
);
return await next(req);
};

Expand Down

0 comments on commit bb65ece

Please sign in to comment.