update readme

This commit is contained in:
flopetautschnig 2023-04-24 14:04:27 +02:00 committed by GitHub
parent 8465db1d3e
commit 2adcceb91b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,2 +1,31 @@
# zerve
A simple framework for writing web services in zig.
# zerve
A simple framework for writing web services in zig.
## Create a simple web app
```zig
usingnamespace @import("zerve");
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);
}
```