blob: d2f9a1f3cb305e9b9e5c1131067f48cc374713ae (
plain)
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
|
const std = @import("std");
const backend = @import("backend");
const httpz = @import("httpz");
const tests = @import("tests.zig");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
var server = try httpz.Server(void).init(allocator, .{
.address = .all(6969),
}, {});
defer {
server.stop();
server.deinit();
}
var router = try server.router(.{});
router.get("/", index, .{});
try server.listen();
}
fn index(_: *httpz.Request, res: *httpz.Response) !void {
res.status = 200;
try res.json(.{.status = "OK"}, .{});
}
test "TestRunner" {
std.testing.refAllDecls(@This());
}
|