46 lines
956 B
Go
46 lines
956 B
Go
|
// Package util ...
|
||
|
//
|
||
|
// Description : util ...
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 2024-04-22 11:15
|
||
|
package util
|
||
|
|
||
|
import (
|
||
|
"git.zhangdeman.cn/zhangdeman/consts"
|
||
|
"net/http"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// GetParameterDefaultLocation 获取参数的默认位置
|
||
|
//
|
||
|
// Author : go_developer@163.com<白茶清欢>
|
||
|
//
|
||
|
// Date : 11:16 2024/4/22
|
||
|
func GetParameterDefaultLocation(requestMethod string) string {
|
||
|
requestMethod = strings.ToUpper(requestMethod)
|
||
|
// 没指定参数位置
|
||
|
switch requestMethod {
|
||
|
case http.MethodGet:
|
||
|
fallthrough
|
||
|
case http.MethodHead:
|
||
|
fallthrough
|
||
|
case http.MethodConnect:
|
||
|
fallthrough
|
||
|
case http.MethodOptions:
|
||
|
fallthrough
|
||
|
case http.MethodTrace:
|
||
|
return consts.RequestLocationQuery
|
||
|
case http.MethodPost:
|
||
|
fallthrough
|
||
|
case http.MethodPut:
|
||
|
fallthrough
|
||
|
case http.MethodPatch: // RFC 5789
|
||
|
fallthrough
|
||
|
case http.MethodDelete:
|
||
|
return consts.RequestLocationBody
|
||
|
}
|
||
|
return consts.RequestLocationQuery
|
||
|
}
|