Skip to content

Commit

Permalink
feat: add path parameter to the request handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-tkachenko committed Aug 11, 2023
1 parent 984937a commit b5c3896
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Prxi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Prxi {
): Promise<void> => {
this.logInfo(`[${requestId}] [Prxi] Handling HTTP proxy request for path: ${path}`);
await proxy.http.proxy(requestId, req, res, proxyConfiguration);
}).catch((err) => {
}, path).catch((err) => {
this.logError(`[${requestId}] [Prxi] Error occurred upon making the "${req.method}:${path}" request`, err);
errorHandler(req, res, err).catch(err => {
this.logError(`[${requestId}] [Prxi] Unable to handle error with errorHandler`, err);
Expand Down Expand Up @@ -133,7 +133,7 @@ export class Prxi {
handler.handle(req, socket, head, async (proxyConfiguration?: ProxyRequestConfiguration): Promise<void> => {
this.logInfo(`[${requestId}] [Prxi] Handling WS proxy request for path: ${path}`);
await proxy.ws.proxy(requestId, req, socket, head, proxyConfiguration);
})
}, path)
.catch(err => {
this.logError(`[${requestId}] [Prxi] Unable to handle websocket request`, err);

Expand Down Expand Up @@ -251,7 +251,7 @@ export class Prxi {
res();
});
});
} else {Prxi
} else {
this.logInfo('Prxi stopping skipped, not running');
}

Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/RequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ export type HandleFunction = (
req: IncomingMessage,
res: ServerResponse,
proxyRequest: ProxyRequest,
path: string
) => Promise<void>;

export type WebSocketHandlerFunction = (
req: IncomingMessage,
socket: Socket,
head: Buffer,
proxyRequest: ProxyRequest,
path: string
) => Promise<void>;

export interface WebSocketHandlerConfig {
Expand Down

0 comments on commit b5c3896

Please sign in to comment.