1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
zap/wrk/http.zig/main.zig
2023-08-24 11:49:58 +02:00

24 lines
697 B
Zig

const httpz = @import("httpz");
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
var server = try httpz.Server().init(allocator, .{ .port = 5882 });
var router = server.router();
// use get/post/put/head/patch/options/delete
// you can also use "all" to attach to all methods
router.get("/", getRequest);
// start the server in the current thread, blocking.
try server.listen();
}
fn getRequest(req: *httpz.Request, res: *httpz.Response) !void {
// try res.json(.{ .id = req.param("id").?, .name = "Teg" }, .{});
_ = req;
res.body = "Hello http.zig!!!";
}