Closed zachary822 closed 3 months ago
No, you have to settle for setting a custom notFound and errorHandler, and putting the logic into those.
server.notFound(notFound);
server.errorHandler(errorHandler);
// ...
fn notFound(_: *httpz.Request, res: *httpz.Response) !void {
res.status = 404;
res.body = "Not Found";
}
fn errorHandler(req: *httpz.Request, res: *httpz.Response, err: anyerror) void {
res.status = 500;
res.body = "Internal Server Error";
std.log.warn("httpz: unhandled exception for request: {s}\nErr: {}", .{req.url.raw, err});
}
Is it possible to run the custom dispatcher on all requests (including 404 and 500)? I want to do some logging for all requests.