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

in http.methodToEnum use std.meta.stringToEnum

This commit is contained in:
Rene Schallner 2024-02-24 15:18:03 +01:00
parent 92e4a54362
commit db579a99f0

View file

@ -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;
}