aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/hello-body.zig4
-rw-r--r--src/api/hello-json.zig4
-rw-r--r--src/api/hello-param.zig6
-rw-r--r--src/api/root.zig2
4 files changed, 9 insertions, 7 deletions
diff --git a/src/api/hello-body.zig b/src/api/hello-body.zig
index 2e5a09e..43afb87 100644
--- a/src/api/hello-body.zig
+++ b/src/api/hello-body.zig
@@ -12,9 +12,9 @@ const Body = struct {
};
fn post(request: Ctx.Request) Response {
- const body = request.json(Body) catch return .bad_request(.void);
+ const body = request.json(Body) catch return .badRequest(.void);
- return .ok_or_error(.json(request.arena, .{
+ return .okOrError(.json(request.arena, .{
.value = body.value,
}));
}
diff --git a/src/api/hello-json.zig b/src/api/hello-json.zig
index 7c96c29..12f1e72 100644
--- a/src/api/hello-json.zig
+++ b/src/api/hello-json.zig
@@ -2,13 +2,13 @@ const http = @import("http");
const Context = http.handler.Context;
const Response = http.Response;
-const Ctx = Context(.{ "hello-json" });
+const Ctx = Context(.{"hello-json"});
pub const ctx: Ctx = .{
.get = get,
};
fn get(request: Ctx.Request) Response {
- return .ok_or_error(.json(request.arena, .{
+ return .okOrError(.json(request.arena, .{
.value = 42,
.message = "Hello, Json!",
}));
diff --git a/src/api/hello-param.zig b/src/api/hello-param.zig
index ba798af..b67212b 100644
--- a/src/api/hello-param.zig
+++ b/src/api/hello-param.zig
@@ -8,7 +8,9 @@ pub const ctx: Ctx = .{
};
fn get(request: Ctx.Request) Response {
- const value = request.params.value.as(usize) catch return .bad_request(.string("parameter needs to be an int"));
+ const value = request.params.value.as(usize) catch return .badRequest(.string("parameter needs to be an int"));
- return .ok_or_error(.json(request.arena, .{ .value = value, }));
+ return .okOrError(.json(request.arena, .{
+ .value = value,
+ }));
}
diff --git a/src/api/root.zig b/src/api/root.zig
index 7570a76..2a54b91 100644
--- a/src/api/root.zig
+++ b/src/api/root.zig
@@ -16,7 +16,7 @@ pub const interfaces: []const Interface = ifs: {
var ifs: []const Interface = &.{};
for (modules) |module| {
- const interface: []const Interface = &.{ module.ctx.interface() };
+ const interface: []const Interface = &.{module.ctx.interface()};
ifs = ifs ++ interface;
}