A simple framework for writing web services in zig. https://github.com/floscodes/zerve
Find a file
2023-04-24 14:13:48 +02:00
src Delete main.zig 2023-04-24 12:12:42 +02:00
build.zig make lib and zig.mod 2023-04-23 14:12:56 +02:00
gyro.zzz add gyro.zzz 2023-04-24 12:15:06 +02:00
LICENSE Create LICENSE 2023-04-24 12:13:17 +02:00
README.md Update README.md 2023-04-24 14:13:48 +02:00
zig.mod Update zig.mod 2023-04-24 12:17:33 +02:00

zerve

A simple framework for writing web services in zig.

Create a simple web app

const zrv = @import("zerve");
const Request = zrv.Request;
const Response = zrv.Response;
const Server = zrv.Server;
const allocator = std.heap.page_allocator;

fn index(req: Request) Response {
    _=req;
    return Response.new("hello!");
}

fn about(req: Request) Response {
    _=req;
    return Response.new("about site");
}

fn writeJson(req: Request) Response {
    _=req;
    Response.json("[1, 2, 3, 4]");
}

pub fn main() !void {
     const rt = [_]Route{.{"/", index}, .{"/about", about}, .{"/json", writeJson}};

     try Server.listen("0.0.0.0", 8080, &rt, allocator);
}