1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00
This commit is contained in:
Rene Schallner 2023-01-14 16:44:40 +01:00
parent cd18bffc62
commit 80185931c5
5 changed files with 14 additions and 13 deletions

View file

@ -23,7 +23,7 @@ pub fn build(b: *std.build.Builder) !void {
.{ .name = "routes", .src = "examples/routes/routes.zig" }, .{ .name = "routes", .src = "examples/routes/routes.zig" },
.{ .name = "serve", .src = "examples/serve/serve.zig" }, .{ .name = "serve", .src = "examples/serve/serve.zig" },
.{ .name = "hello_json", .src = "examples/hello_json/hello_json.zig" }, .{ .name = "hello_json", .src = "examples/hello_json/hello_json.zig" },
.{ .name = "endpoint", .src = "examples/endpoint/main.zig" }, .{ .name = "endpoints", .src = "examples/endpoints/main.zig" },
}) |excfg| { }) |excfg| {
const ex_name = excfg.name; const ex_name = excfg.name;
const ex_src = excfg.src; const ex_src = excfg.src;

View file

@ -11,6 +11,7 @@ pub fn main() !void {
.port = 3000, .port = 3000,
.on_request = null, .on_request = null,
.log = true, .log = true,
.public_folder = "./examples/endpoints/html",
}, },
); );

View file

@ -98,18 +98,18 @@ pub const SimpleRequest = struct {
// C.fiobj_free(new_fiobj_str); // C.fiobj_free(new_fiobj_str);
} }
pub fn nextParam(self: *const Self) ?HttpParam { // pub fn nextParam(self: *const Self) ?HttpParam {
if (self.h.*.params == 0) return null; // if (self.h.*.params == 0) return null;
var key: C.FIOBJ = undefined; // var key: C.FIOBJ = undefined;
const value = C.fiobj_hash_pop(self.h.*.params, &key); // const value = C.fiobj_hash_pop(self.h.*.params, &key);
if (value == C.FIOBJ_INVALID) { // if (value == C.FIOBJ_INVALID) {
return null; // return null;
} // }
return HttpParam{ // return HttpParam{
.key = fio2str(key).?, // .key = fio2str(key).?,
.value = fio2str(value).?, // .value = fio2str(value).?,
}; // };
} // }
}; };
pub const HttpRequestFn = *const fn (r: [*c]C.http_s) callconv(.C) void; pub const HttpRequestFn = *const fn (r: [*c]C.http_s) callconv(.C) void;