1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
zap/examples/senderror/senderror.zig
2023-05-22 05:17:21 +02:00

28 lines
568 B
Zig

const std = @import("std");
const zap = @import("zap");
fn MAKE_MEGA_ERROR() !void {
return error.MEGA_ERROR;
}
fn MY_REQUEST_HANDLER(r: zap.SimpleRequest) void {
MAKE_MEGA_ERROR() catch |err| {
r.sendError(err, 505);
};
}
pub fn main() !void {
var listener = zap.SimpleHttpListener.init(.{
.port = 3000,
.on_request = MY_REQUEST_HANDLER,
.log = true,
});
try listener.listen();
std.debug.print("Listening on 0.0.0.0:3000\n", .{});
zap.start(.{
.threads = 2,
.workers = 2,
});
}