aboutsummaryrefslogtreecommitdiff
path: root/src/http/handler/root.zig
blob: 634888c9d87c27bf02e9b4c0ef9f45bc40a226e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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,
        };

        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)));
        }
    };

    _ = M.context.interface();
}