mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
endpoint auth : sending unauthorized
This commit is contained in:
parent
208a443685
commit
56121ced9a
1 changed files with 8 additions and 8 deletions
|
@ -86,8 +86,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
|||
pub fn get(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||
// TODO: return 401
|
||||
std.debug.print("401\n", .{});
|
||||
r.setStatus(.unauthorized);
|
||||
r.sendBody("UNAUTHORIZED") catch return;
|
||||
return;
|
||||
}
|
||||
// auth successful
|
||||
|
@ -98,8 +98,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
|||
pub fn post(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||
// TODO: return 401
|
||||
std.debug.print("401\n", .{});
|
||||
r.setStatus(.unauthorized);
|
||||
r.sendBody("UNAUTHORIZED") catch return;
|
||||
return;
|
||||
}
|
||||
// auth successful
|
||||
|
@ -110,8 +110,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
|||
pub fn put(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||
// todo: return 401
|
||||
std.debug.print("401\n", .{});
|
||||
r.setStatus(.unauthorized);
|
||||
r.sendBody("UNAUTHORIZED") catch return;
|
||||
return;
|
||||
}
|
||||
// auth successful
|
||||
|
@ -122,8 +122,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
|||
pub fn delete(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||
// todo: return 401
|
||||
std.debug.print("401\n", .{});
|
||||
r.setStatus(.unauthorized);
|
||||
r.sendBody("UNAUTHORIZED") catch return;
|
||||
return;
|
||||
}
|
||||
// auth successful
|
||||
|
|
Loading…
Add table
Reference in a new issue