From e3572d7691659c2c2006acb059f973f7ca05ece1 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Fri, 8 Mar 2024 20:08:28 -0800 Subject: [PATCH] - Added more logging. --- packages/http/src/commands/file-server.command.ts | 2 ++ packages/http/src/servers/file.http-server.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/http/src/commands/file-server.command.ts b/packages/http/src/commands/file-server.command.ts index f2eb6b94..7604674f 100644 --- a/packages/http/src/commands/file-server.command.ts +++ b/packages/http/src/commands/file-server.command.ts @@ -21,6 +21,8 @@ export class FileServerCommand implements CommandInterface { await this.fileHttpServer.start(args.directory ?? "./", args.port, args.address, (port, address) => { this.consoleManager.writeLine(`Pristine HTTP File server listening on: '${address}:${port}'`); + }, (req) => { + this.consoleManager.writeLine(`Request received: ${req.url}`); }); return ExitCodeEnum.Success; diff --git a/packages/http/src/servers/file.http-server.ts b/packages/http/src/servers/file.http-server.ts index 0fdb787c..40dc244e 100644 --- a/packages/http/src/servers/file.http-server.ts +++ b/packages/http/src/servers/file.http-server.ts @@ -25,7 +25,7 @@ export class FileHttpServer { return 0; } - async start(directory: string, port?: number, address?: string, listeningCallback?: (port?: number, address?: string) => void) { + async start(directory: string, port?: number, address?: string, listeningCallback?: (port?: number, address?: string) => void, requestCallback?:(req: IncomingMessage) => void) { port = port ?? this.getPort(); address = address ?? this.address; @@ -36,6 +36,8 @@ export class FileHttpServer { return; } + requestCallback?.(req); + this.logHandler.info("Request received: " + req.url, {req, directory, port, address}); // parse URL