Cleaning up performance branch

This commit is contained in:
Manu Mtz-Almeida
2015-04-07 12:22:38 +02:00
parent 3faa81a464
commit 1f6304ca25
6 changed files with 127 additions and 135 deletions

View File

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