1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00

cleanup unused params where applicable (ie non-instructive)

This commit is contained in:
renerocksai 2025-03-30 19:58:22 +02:00
parent 4c59132a08
commit 3a2246ba50
No known key found for this signature in database
6 changed files with 10 additions and 16 deletions

View file

@ -7,9 +7,7 @@ pub const ErrorEndpoint = @This();
path: []const u8 = "/error",
error_strategy: zap.Endpoint.ErrorStrategy = .log_to_response,
pub fn get(e: *ErrorEndpoint, r: zap.Request) !void {
_ = e;
_ = r;
pub fn get(_: *ErrorEndpoint, _: zap.Request) !void {
return error.@"Oh-no!";
}

View file

@ -14,9 +14,7 @@ pub fn init(path: []const u8) StopEndpoint {
};
}
pub fn get(e: *StopEndpoint, r: zap.Request) !void {
_ = e;
_ = r;
pub fn get(_: *StopEndpoint, _: zap.Request) !void {
zap.stop();
}

View file

@ -125,8 +125,9 @@ fn handle_websocket_message(
message: []const u8,
is_text: bool,
) void {
_ = is_text;
_ = handle;
_ = is_text;
if (context) |ctx| {
// send message
const buflen = 128; // arbitrary len

View file

@ -43,9 +43,7 @@
//! pub fn patch(_: *StopEndpoint, _: zap.Request) void {}
//! pub fn options(_: *StopEndpoint, _: zap.Request) void {}
//!
//! pub fn get(self: *StopEndpoint, r: zap.Request) void {
//! _ = self;
//! _ = r;
//! pub fn get(_: *StopEndpoint, _: zap.Request) void {
//! zap.stop();
//! }
//! };

View file

@ -63,8 +63,7 @@ pub fn handle_func_unbound(self: *Router, path: []const u8, h: zap.HttpRequestFn
///
/// ```zig
/// const HandlerType = struct {
/// pub fn getA(self: *HandlerType, r: zap.Request) void {
/// _ = self;
/// pub fn getA(_: *HandlerType, r: zap.Request) void {
/// r.sendBody("hello\n\n") catch return;
/// }
/// }

View file

@ -151,16 +151,14 @@ pub const Endpoint = struct {
path: []const u8,
error_strategy: zap.Endpoint.ErrorStrategy = .raise,
pub fn get(e: *Endpoint, r: zap.Request) !void {
_ = e;
pub fn get(_: *Endpoint, r: zap.Request) !void {
r.sendBody(HTTP_RESPONSE) catch return;
received_response = HTTP_RESPONSE;
std.time.sleep(1 * std.time.ns_per_s);
zap.stop();
}
pub fn unauthorized(e: *Endpoint, r: zap.Request) !void {
_ = e;
pub fn unauthorized(_: *Endpoint, r: zap.Request) !void {
r.setStatus(.unauthorized);
r.sendBody("UNAUTHORIZED ACCESS") catch return;
received_response = "UNAUTHORIZED";
@ -590,6 +588,8 @@ test "BasicAuth UserPass authenticateRequest test-unauthorized" {
var encoder = std.base64.url_safe.Encoder;
var buffer: [256]u8 = undefined;
const encoded = encoder.encode(&buffer, token);
// not interested in the encoded auth string; we want unauthorized
_ = encoded;
// create authenticator