mirror of
https://github.com/labstack/echo.git
synced 2025-04-23 12:18:53 +02:00
parent
3f5b733425
commit
54efc3850d
@ -54,7 +54,7 @@ func TestBindingError_Error(t *testing.T) {
|
|||||||
func TestBindingError_ErrorJSON(t *testing.T) {
|
func TestBindingError_ErrorJSON(t *testing.T) {
|
||||||
err := NewBindingError("id", []string{"1", "nope"}, "bind failed", errors.New("internal error"))
|
err := NewBindingError("id", []string{"1", "nope"}, "bind failed", errors.New("internal error"))
|
||||||
|
|
||||||
resp, err := json.Marshal(err)
|
resp, _ := json.Marshal(err)
|
||||||
|
|
||||||
assert.Equal(t, `{"field":"id","message":"bind failed"}`, string(resp))
|
assert.Equal(t, `{"field":"id","message":"bind failed"}`, string(resp))
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package echo
|
package echo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@ -2446,33 +2445,3 @@ func BenchmarkRouterGooglePlusAPIMisses(b *testing.B) {
|
|||||||
func BenchmarkRouterParamsAndAnyAPI(b *testing.B) {
|
func BenchmarkRouterParamsAndAnyAPI(b *testing.B) {
|
||||||
benchmarkRouterRoutes(b, paramAndAnyAPI, paramAndAnyAPIToFind)
|
benchmarkRouterRoutes(b, paramAndAnyAPI, paramAndAnyAPIToFind)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) printTree(pfx string, tail bool) {
|
|
||||||
p := prefix(tail, pfx, "└── ", "├── ")
|
|
||||||
fmt.Printf("%s%s, %p: type=%d, parent=%p, handler=%v, pnames=%v\n", p, n.prefix, n, n.kind, n.parent, n.methodHandler, n.pnames)
|
|
||||||
|
|
||||||
p = prefix(tail, pfx, " ", "│ ")
|
|
||||||
|
|
||||||
children := n.staticChildren
|
|
||||||
l := len(children)
|
|
||||||
|
|
||||||
if n.paramChild != nil {
|
|
||||||
n.paramChild.printTree(p, n.anyChild == nil && l == 0)
|
|
||||||
}
|
|
||||||
if n.anyChild != nil {
|
|
||||||
n.anyChild.printTree(p, l == 0)
|
|
||||||
}
|
|
||||||
for i := 0; i < l-1; i++ {
|
|
||||||
children[i].printTree(p, false)
|
|
||||||
}
|
|
||||||
if l > 0 {
|
|
||||||
children[l-1].printTree(p, true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func prefix(tail bool, p, on, off string) string {
|
|
||||||
if tail {
|
|
||||||
return fmt.Sprintf("%s%s", p, on)
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s%s", p, off)
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user