From db579a99f08a06d2424b25c9e610a84b7d8d7dd6 Mon Sep 17 00:00:00 2001 From: Rene Schallner Date: Sat, 24 Feb 2024 15:18:03 +0100 Subject: [PATCH] in http.methodToEnum use std.meta.stringToEnum --- src/http.zig | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/http.zig b/src/http.zig index 94e25d4..5241c3f 100644 --- a/src/http.zig +++ b/src/http.zig @@ -117,21 +117,11 @@ pub const Method = enum { OPTIONS, UNKNOWN, }; + pub fn methodToEnum(method: ?[]const u8) Method { { if (method) |m| { - if (std.mem.eql(u8, m, "GET")) - return Method.GET; - if (std.mem.eql(u8, m, "POST")) - return Method.POST; - if (std.mem.eql(u8, m, "PUT")) - return Method.PUT; - if (std.mem.eql(u8, m, "DELETE")) - return Method.DELETE; - if (std.mem.eql(u8, m, "PATCH")) - return Method.PATCH; - if (std.mem.eql(u8, m, "OPTIONS")) - return Method.OPTIONS; + return std.meta.stringToEnum(Method, m) orelse .UNKNOWN; } return Method.UNKNOWN; }