util/http: fix lint issues
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
7838fa62a8
commit
1829febb6e
@ -4,6 +4,7 @@ package http
|
|||||||
// Armon Dadgar in https://github.com/armon/go-radix/blob/master/radix.go
|
// Armon Dadgar in https://github.com/armon/go-radix/blob/master/radix.go
|
||||||
// (MIT licensed). It's been heavily modified for use as a HTTP routing tree.
|
// (MIT licensed). It's been heavily modified for use as a HTTP routing tree.
|
||||||
// Copied from chi mux tree.go https://raw.githubusercontent.com/go-chi/chi/master/tree.go
|
// Copied from chi mux tree.go https://raw.githubusercontent.com/go-chi/chi/master/tree.go
|
||||||
|
// Modified by Unistack LLC to support interface{} type handler and parameters in map[string]string
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -75,7 +76,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewTrie() *Node {
|
func NewTrie() *Node {
|
||||||
return &Node{typ: ntStatic}
|
return &Node{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
@ -107,12 +108,12 @@ type Node struct {
|
|||||||
type endpoints map[methodTyp]*endpoint
|
type endpoints map[methodTyp]*endpoint
|
||||||
|
|
||||||
type endpoint struct {
|
type endpoint struct {
|
||||||
// parameters keys recorded on handler nodes
|
|
||||||
paramKeys []string
|
|
||||||
// endpoint handler
|
// endpoint handler
|
||||||
handler interface{}
|
handler interface{}
|
||||||
// pattern is the routing pattern for handler nodes
|
// pattern is the routing pattern for handler nodes
|
||||||
pattern string
|
pattern string
|
||||||
|
// parameters keys recorded on handler nodes
|
||||||
|
paramKeys []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s endpoints) Value(method methodTyp) *endpoint {
|
func (s endpoints) Value(method methodTyp) *endpoint {
|
||||||
@ -273,7 +274,8 @@ func (n *Node) addChild(child *Node, prefix string) (*Node, error) {
|
|||||||
child.rex = rex
|
child.rex = rex
|
||||||
}
|
}
|
||||||
|
|
||||||
if segStartIdx == 0 {
|
switch {
|
||||||
|
case segStartIdx == 0:
|
||||||
// Route starts with a param
|
// Route starts with a param
|
||||||
child.typ = segTyp
|
child.typ = segTyp
|
||||||
|
|
||||||
@ -306,7 +308,7 @@ func (n *Node) addChild(child *Node, prefix string) (*Node, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if segStartIdx > 0 {
|
case segStartIdx > 0:
|
||||||
// Route has some param
|
// Route has some param
|
||||||
|
|
||||||
// starts with a static segment
|
// starts with a static segment
|
||||||
|
Loading…
Reference in New Issue
Block a user