Cosmetic changes

This commit is contained in:
Manu Mtz.-Almeida
2016-01-28 00:35:09 +01:00
parent 97cd894279
commit d64a1fb91c
5 changed files with 18 additions and 29 deletions

20
gin.go
View File

@ -178,25 +178,15 @@ func (engine *Engine) rebuild405Handlers() {
}
func (engine *Engine) addRoute(method, path string, handlers HandlersChain) {
assert1(path[0] == '/', "path must begin with '/'")
assert1(len(method) > 0, "HTTP method can not be empty")
assert1(len(handlers) > 0, "there must be at least one handler")
debugPrintRoute(method, path, handlers)
if path[0] != '/' {
panic("path must begin with '/'")
}
if method == "" {
panic("HTTP method can not be empty")
}
if len(handlers) == 0 {
panic("there must be at least one handler")
}
root := engine.trees.get(method)
if root == nil {
root = new(node)
engine.trees = append(engine.trees, methodTree{
method: method,
root: root,
})
engine.trees = append(engine.trees, methodTree{method: method, root: root})
}
root.addRoute(path, handlers)
}