mirror of
https://github.com/zigzap/zap.git
synced 2025-10-21 07:34:08 +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 {
|
pub fn get(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||||
// TODO: return 401
|
r.setStatus(.unauthorized);
|
||||||
std.debug.print("401\n", .{});
|
r.sendBody("UNAUTHORIZED") catch return;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// auth successful
|
// auth successful
|
||||||
|
@ -98,8 +98,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
||||||
pub fn post(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
pub fn post(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||||
// TODO: return 401
|
r.setStatus(.unauthorized);
|
||||||
std.debug.print("401\n", .{});
|
r.sendBody("UNAUTHORIZED") catch return;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// auth successful
|
// auth successful
|
||||||
|
@ -110,8 +110,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
||||||
pub fn put(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
pub fn put(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||||
// todo: return 401
|
r.setStatus(.unauthorized);
|
||||||
std.debug.print("401\n", .{});
|
r.sendBody("UNAUTHORIZED") catch return;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// auth successful
|
// auth successful
|
||||||
|
@ -122,8 +122,8 @@ pub fn AuthenticatingEndpoint(comptime Authenticator: type) type {
|
||||||
pub fn delete(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
pub fn delete(e: *SimpleEndpoint, r: zap.SimpleRequest) void {
|
||||||
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
const authEp: *Self = @fieldParentPtr(Self, "auth_endpoint", e);
|
||||||
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
if (authEp.authenticator.authenticateRequest(&r) == false) {
|
||||||
// todo: return 401
|
r.setStatus(.unauthorized);
|
||||||
std.debug.print("401\n", .{});
|
r.sendBody("UNAUTHORIZED") catch return;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// auth successful
|
// auth successful
|
||||||
|
|
Loading…
Add table
Reference in a new issue