1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +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 = "serve", .src = "examples/serve/serve.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| {
const ex_name = excfg.name;
const ex_src = excfg.src;

View file

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

View file

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