-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathsenderror.zig
More file actions
34 lines (29 loc) · 733 Bytes
/
senderror.zig
File metadata and controls
34 lines (29 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//!
//! Part of the Zap examples.
//!
//! Build me with `zig build senderror`.
//! Run me with `zig build run-senderror`.
//!
const std = @import("std");
const zap = @import("zap");
fn MAKE_MEGA_ERROR() !void {
return error.MEGA_ERROR;
}
fn MY_REQUEST_HANDLER(r: zap.Request) !void {
MAKE_MEGA_ERROR() catch |err| {
r.sendError(err, if (@errorReturnTrace()) |t| t.* else null, 505);
};
}
pub fn main() !void {
var listener = zap.HttpListener.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,
});
}