Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调整枚举函数 #100

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 35 additions & 16 deletions TigoWeb/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,45 @@ package TigoWeb

const Version = "1.6.5"

const (
httpLowerGet = "get"
httpLowerHead = "head"
httpLowerPost = "post"
httpLowerPut = "put"
httpLowerDelete = "delete"
httpLowerConnect = "connect"
httpLowerOptions = "options"
httpLowerTrace = "trace"
httpUpperGet = "GET"
httpUpperHead = "HEAD"
httpUpperPost = "POST"
httpUpperPut = "PUT"
httpUpperDelete = "DELETE"
httpUpperConnect = "CONNECT"
httpUpperOptions = "OPTIONS"
httpUpperTrace = "TRACE"
)

// MethodEnum 根据http请求方式获取对应的函数名
// - httpMethod: http请求方式
func MethodEnum(httpMethod string) string {
var MethodMapping = map[string]string{
"get": "Get",
"head": "Head",
"post": "Post",
"put": "Put",
"delete": "Delete",
"connect": "Connect",
"options": "Options",
"trace": "Trace",
"GET": "Get",
"HEAD": "Head",
"POST": "Post",
"PUT": "Put",
"DELETE": "Delete",
"CONNECT": "Connect",
"OPTIONS": "Options",
"TRACE": "Trace",
httpLowerGet: "Get",
httpLowerHead: "Head",
httpLowerPost: "Post",
httpLowerPut: "Put",
httpLowerDelete: "Delete",
httpLowerConnect: "Connect",
httpLowerOptions: "Options",
httpLowerTrace: "Trace",
httpUpperGet: "Get",
httpUpperHead: "Head",
httpUpperPost: "Post",
httpUpperPut: "Put",
httpUpperDelete: "Delete",
httpUpperConnect: "Connect",
httpUpperOptions: "Options",
httpUpperTrace: "Trace",
}
return MethodMapping[httpMethod]
}