diff options
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(); +} |