mirror of
https://github.com/gin-gonic/gin.git
synced 2025-08-06 07:40:39 +08:00
Cleaning up performance branch
This commit is contained in:
42
utils.go
42
utils.go
@ -7,23 +7,12 @@ package gin
|
||||
import (
|
||||
"encoding/xml"
|
||||
"log"
|
||||
"path"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
methodGET = iota
|
||||
methodPOST = iota
|
||||
methodPUT = iota
|
||||
methodAHEAD = iota
|
||||
methodOPTIONS = iota
|
||||
methodDELETE = iota
|
||||
methodCONNECT = iota
|
||||
methodTRACE = iota
|
||||
methodUnknown = iota
|
||||
)
|
||||
|
||||
type H map[string]interface{}
|
||||
|
||||
// Allows type H to be used with xml.Marshal
|
||||
@ -93,25 +82,14 @@ func nameOfFunction(f interface{}) string {
|
||||
return runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
|
||||
}
|
||||
|
||||
func codeForHTTPMethod(method string) int {
|
||||
switch method {
|
||||
case "GET":
|
||||
return methodGET
|
||||
case "POST":
|
||||
return methodPOST
|
||||
case "PUT":
|
||||
return methodPUT
|
||||
case "AHEAD":
|
||||
return methodAHEAD
|
||||
case "OPTIONS":
|
||||
return methodOPTIONS
|
||||
case "DELETE":
|
||||
return methodDELETE
|
||||
case "TRACE":
|
||||
return methodTRACE
|
||||
case "CONNECT":
|
||||
return methodCONNECT
|
||||
default:
|
||||
return methodUnknown
|
||||
func joinPaths(absolutePath, relativePath string) string {
|
||||
if len(relativePath) == 0 {
|
||||
return absolutePath
|
||||
}
|
||||
absolutePath = path.Join(absolutePath, relativePath)
|
||||
appendSlash := lastChar(relativePath) == '/' && lastChar(absolutePath) != '/'
|
||||
if appendSlash {
|
||||
return absolutePath + "/"
|
||||
}
|
||||
return absolutePath
|
||||
}
|
||||
|
Reference in New Issue
Block a user