diff options
| -rw-r--r-- | src/api/hello-body.zig | 4 | ||||
| -rw-r--r-- | src/api/hello-json.zig | 2 | ||||
| -rw-r--r-- | src/api/hello-param.zig | 4 | ||||
| -rw-r--r-- | src/http/Response.zig | 4 |
4 files changed, 7 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..6c29ba7 100644 --- a/src/api/hello-json.zig +++ b/src/api/hello-json.zig @@ -8,7 +8,7 @@ pub const ctx: Ctx = .{ }; 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..f4de1dd 100644 --- a/src/api/hello-param.zig +++ b/src/api/hello-param.zig @@ -8,7 +8,7 @@ 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/http/Response.zig b/src/http/Response.zig index d54792b..5745899 100644 --- a/src/http/Response.zig +++ b/src/http/Response.zig @@ -36,11 +36,11 @@ pub fn ok(message: Message) @This() { return with(.ok, message); } -pub fn ok_or_error(message: anyerror!Message) @This() { +pub fn okOrError(message: anyerror!Message) @This() { return ok(message catch return with(.internal_server_error, .void)); } -pub fn bad_request(message: Message) @This() { +pub fn badRequest(message: Message) @This() { return with(.bad_request, message); } |