mirror of
https://github.com/zigzap/zap.git
synced 2025-10-20 15:14:08 +00:00
performance: revert r.method enum back to ?[]const u8 new http.Method enum is available via r.methodAsEnum()
This commit is contained in:
parent
30c5b392a9
commit
5ea15b8a3e
3 changed files with 11 additions and 10 deletions
|
@ -2,7 +2,8 @@ const std = @import("std");
|
|||
const zap = @import("zap");
|
||||
|
||||
fn on_request(r: zap.Request) void {
|
||||
const m = r.method_str orelse "";
|
||||
const m = r.methodAsEnum();
|
||||
const m_str = r.method orelse "";
|
||||
const p = r.path orelse "/";
|
||||
const qm = if (r.query) |_| "?" else "";
|
||||
const qq = r.query orelse "";
|
||||
|
@ -13,7 +14,7 @@ fn on_request(r: zap.Request) void {
|
|||
} else {
|
||||
std.debug.print(">> Special Header: <unknown>\n", .{});
|
||||
}
|
||||
std.debug.print(">> {s} {s}{s}{s}\n", .{ m, p, qm, qq });
|
||||
std.debug.print(">> {s}({}) {s}{s}{s}\n", .{ m_str, m, p, qm, qq });
|
||||
|
||||
if (r.body) |the_body| {
|
||||
std.debug.print(">> BODY: {s}\n", .{the_body});
|
||||
|
|
|
@ -266,8 +266,7 @@ pub const CookieArgs = struct {
|
|||
path: ?[]const u8,
|
||||
query: ?[]const u8,
|
||||
body: ?[]const u8,
|
||||
method: http.Method,
|
||||
method_str: ?[]const u8,
|
||||
method: ?[]const u8,
|
||||
h: [*c]fio.http_s,
|
||||
|
||||
/// NEVER touch this field!!!!
|
||||
|
@ -792,3 +791,7 @@ pub fn getParamSlices(self: *const Self) ParamSliceIterator {
|
|||
const query = self.query orelse "";
|
||||
return ParamSliceIterator.init(query);
|
||||
}
|
||||
|
||||
pub fn methodAsEnum(self: *const Self) http.Method {
|
||||
return http.methodToEnum(self.method);
|
||||
}
|
||||
|
|
|
@ -207,8 +207,7 @@ pub const HttpListener = struct {
|
|||
.path = util.fio2str(r.*.path),
|
||||
.query = util.fio2str(r.*.query),
|
||||
.body = util.fio2str(r.*.body),
|
||||
.method = http.methodToEnum(util.fio2str(r.*.method)),
|
||||
.method_str = util.fio2str(r.*.method),
|
||||
.method = util.fio2str(r.*.method),
|
||||
.h = r,
|
||||
._is_finished_request_global = false,
|
||||
._user_context = undefined,
|
||||
|
@ -234,8 +233,7 @@ pub const HttpListener = struct {
|
|||
.path = util.fio2str(r.*.path),
|
||||
.query = util.fio2str(r.*.query),
|
||||
.body = util.fio2str(r.*.body),
|
||||
.method = http.methodToEnum(util.fio2str(r.*.method)),
|
||||
.method_str = util.fio2str(r.*.method),
|
||||
.method = util.fio2str(r.*.method),
|
||||
.h = r,
|
||||
._is_finished_request_global = false,
|
||||
._user_context = undefined,
|
||||
|
@ -256,8 +254,7 @@ pub const HttpListener = struct {
|
|||
.path = util.fio2str(r.*.path),
|
||||
.query = util.fio2str(r.*.query),
|
||||
.body = util.fio2str(r.*.body),
|
||||
.method = http.methodToEnum(util.fio2str(r.*.method)),
|
||||
.method_str = util.fio2str(r.*.method),
|
||||
.method = util.fio2str(r.*.method),
|
||||
.h = r,
|
||||
._is_finished_request_global = false,
|
||||
._user_context = undefined,
|
||||
|
|
Loading…
Add table
Reference in a new issue