diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-06-06 07:57:50 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-06-06 07:57:50 +0200 |
| commit | 51307d973255e32ec1440083dee383e8b2cd8878 (patch) | |
| tree | dac0309c7abd40d2a3822fca3f7df0fd485e04f0 /src/http/handler/root.zig | |
| parent | 17561c6be1e4fba11e243f2ac842ebe26fae7e60 (diff) | |
Implement static handler and synchronous server handling
Diffstat (limited to 'src/http/handler/root.zig')
| -rw-r--r-- | src/http/handler/root.zig | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/http/handler/root.zig b/src/http/handler/root.zig new file mode 100644 index 0000000..33fdb84 --- /dev/null +++ b/src/http/handler/root.zig @@ -0,0 +1,35 @@ +pub const Context = @import("context.zig").Context; +pub const Interface = @import("Interface.zig"); +pub const Static = @import("static.zig").Static; + +test "interface" { + const M = struct { + const Response = @import("../Response.zig"); + + const C = Context(.{ "api", "images", .id, "metadata" }); + const context: C = .{ + .post = post, + .get = get, + }; + + const Query = struct { + condition: []const u8, + start: usize, + length: usize, + }; + + fn post(request: C.Request) Response { + const query = request.json(Query) catch return .with(.bad_request, .void); + _ = query; + _ = request.params.id; + + return .ok(.string(request.params.id.as([]const u8))); + } + + fn get(request: C.Request) Response { + return .ok(Response.Message.file(request.io, "./some/path.txt") catch return .with(.not_found, .void)); + } + }; + + _ = M.context.interface(); +} |