Zero allocation router, first commit

This commit is contained in:
Manu Mtz-Almeida
2015-03-31 21:39:06 +02:00
parent c0e8cedc98
commit 2915fa0ffe
8 changed files with 909 additions and 172 deletions

View File

@ -12,6 +12,18 @@ import (
"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
@ -80,3 +92,26 @@ func lastChar(str string) uint8 {
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
}
}