mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 23:24:09 +00:00
cleanup unused params where applicable (ie non-instructive)
This commit is contained in:
parent
4c59132a08
commit
3a2246ba50
6 changed files with 10 additions and 16 deletions
|
@ -7,9 +7,7 @@ pub const ErrorEndpoint = @This();
|
||||||
path: []const u8 = "/error",
|
path: []const u8 = "/error",
|
||||||
error_strategy: zap.Endpoint.ErrorStrategy = .log_to_response,
|
error_strategy: zap.Endpoint.ErrorStrategy = .log_to_response,
|
||||||
|
|
||||||
pub fn get(e: *ErrorEndpoint, r: zap.Request) !void {
|
pub fn get(_: *ErrorEndpoint, _: zap.Request) !void {
|
||||||
_ = e;
|
|
||||||
_ = r;
|
|
||||||
return error.@"Oh-no!";
|
return error.@"Oh-no!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,7 @@ pub fn init(path: []const u8) StopEndpoint {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(e: *StopEndpoint, r: zap.Request) !void {
|
pub fn get(_: *StopEndpoint, _: zap.Request) !void {
|
||||||
_ = e;
|
|
||||||
_ = r;
|
|
||||||
zap.stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,8 +125,9 @@ fn handle_websocket_message(
|
||||||
message: []const u8,
|
message: []const u8,
|
||||||
is_text: bool,
|
is_text: bool,
|
||||||
) void {
|
) void {
|
||||||
_ = is_text;
|
|
||||||
_ = handle;
|
_ = handle;
|
||||||
|
_ = is_text;
|
||||||
|
|
||||||
if (context) |ctx| {
|
if (context) |ctx| {
|
||||||
// send message
|
// send message
|
||||||
const buflen = 128; // arbitrary len
|
const buflen = 128; // arbitrary len
|
||||||
|
|
|
@ -43,9 +43,7 @@
|
||||||
//! pub fn patch(_: *StopEndpoint, _: zap.Request) void {}
|
//! pub fn patch(_: *StopEndpoint, _: zap.Request) void {}
|
||||||
//! pub fn options(_: *StopEndpoint, _: zap.Request) void {}
|
//! pub fn options(_: *StopEndpoint, _: zap.Request) void {}
|
||||||
//!
|
//!
|
||||||
//! pub fn get(self: *StopEndpoint, r: zap.Request) void {
|
//! pub fn get(_: *StopEndpoint, _: zap.Request) void {
|
||||||
//! _ = self;
|
|
||||||
//! _ = r;
|
|
||||||
//! zap.stop();
|
//! zap.stop();
|
||||||
//! }
|
//! }
|
||||||
//! };
|
//! };
|
||||||
|
|
|
@ -63,8 +63,7 @@ pub fn handle_func_unbound(self: *Router, path: []const u8, h: zap.HttpRequestFn
|
||||||
///
|
///
|
||||||
/// ```zig
|
/// ```zig
|
||||||
/// const HandlerType = struct {
|
/// const HandlerType = struct {
|
||||||
/// pub fn getA(self: *HandlerType, r: zap.Request) void {
|
/// pub fn getA(_: *HandlerType, r: zap.Request) void {
|
||||||
/// _ = self;
|
|
||||||
/// r.sendBody("hello\n\n") catch return;
|
/// r.sendBody("hello\n\n") catch return;
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
|
|
@ -151,16 +151,14 @@ pub const Endpoint = struct {
|
||||||
path: []const u8,
|
path: []const u8,
|
||||||
error_strategy: zap.Endpoint.ErrorStrategy = .raise,
|
error_strategy: zap.Endpoint.ErrorStrategy = .raise,
|
||||||
|
|
||||||
pub fn get(e: *Endpoint, r: zap.Request) !void {
|
pub fn get(_: *Endpoint, r: zap.Request) !void {
|
||||||
_ = e;
|
|
||||||
r.sendBody(HTTP_RESPONSE) catch return;
|
r.sendBody(HTTP_RESPONSE) catch return;
|
||||||
received_response = HTTP_RESPONSE;
|
received_response = HTTP_RESPONSE;
|
||||||
std.time.sleep(1 * std.time.ns_per_s);
|
std.time.sleep(1 * std.time.ns_per_s);
|
||||||
zap.stop();
|
zap.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unauthorized(e: *Endpoint, r: zap.Request) !void {
|
pub fn unauthorized(_: *Endpoint, r: zap.Request) !void {
|
||||||
_ = e;
|
|
||||||
r.setStatus(.unauthorized);
|
r.setStatus(.unauthorized);
|
||||||
r.sendBody("UNAUTHORIZED ACCESS") catch return;
|
r.sendBody("UNAUTHORIZED ACCESS") catch return;
|
||||||
received_response = "UNAUTHORIZED";
|
received_response = "UNAUTHORIZED";
|
||||||
|
@ -590,6 +588,8 @@ test "BasicAuth UserPass authenticateRequest test-unauthorized" {
|
||||||
var encoder = std.base64.url_safe.Encoder;
|
var encoder = std.base64.url_safe.Encoder;
|
||||||
var buffer: [256]u8 = undefined;
|
var buffer: [256]u8 = undefined;
|
||||||
const encoded = encoder.encode(&buffer, token);
|
const encoded = encoder.encode(&buffer, token);
|
||||||
|
|
||||||
|
// not interested in the encoded auth string; we want unauthorized
|
||||||
_ = encoded;
|
_ = encoded;
|
||||||
|
|
||||||
// create authenticator
|
// create authenticator
|
||||||
|
|
Loading…
Add table
Reference in a new issue