blob: b67212b7494260acc09a9980a8f7029cd7460bbc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
const http = @import("http");
const Context = http.handler.Context;
const Response = http.Response;
const Ctx = Context(.{ "hello-param", .value });
pub const ctx: Ctx = .{
.get = get,
};
fn get(request: Ctx.Request) Response {
const value = request.params.value.as(usize) catch return .badRequest(.string("parameter needs to be an int"));
return .okOrError(.json(request.arena, .{
.value = value,
}));
}
|