Skip to content

Commit

Permalink
in http.methodToEnum use std.meta.stringToEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
renerocksai committed Feb 24, 2024
1 parent 92e4a54 commit db579a9
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/http.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit db579a9

Please sign in to comment.