blob: 33fdb84c55eadafc38397713f941251439a5f11a (
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
31
32
33
34
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();
}
|