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:
parent
0d712282e2
commit
30c5b392a9
1 changed files with 2 additions and 12 deletions
14
src/http.zig
14
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue