mirror of
https://github.com/labstack/echo.git
synced 2025-01-01 22:09:21 +02:00
Merge pull request #539 from o1egl/patch1
Query params and router tests fix
This commit is contained in:
commit
98a822e8d7
14
echo_test.go
14
echo_test.go
@ -236,9 +236,17 @@ func TestEchoRoutes(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
for i, r := range e.Routes() {
|
||||
assert.Equal(t, routes[i].Method, r.Method)
|
||||
assert.Equal(t, routes[i].Path, r.Path)
|
||||
for _, r := range e.Routes() {
|
||||
found := false
|
||||
for _, rr := range routes {
|
||||
if r.Method == rr.Method && r.Path == rr.Path {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("Route %s : %s not found", r.Method, r.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +30,11 @@ func (u *URL) QueryParam(name string) string {
|
||||
func (u *URL) QueryParams() (params map[string][]string) {
|
||||
params = make(map[string][]string)
|
||||
u.QueryArgs().VisitAll(func(k, v []byte) {
|
||||
// TODO: Filling with only first value
|
||||
params[string(k)] = []string{string(v)}
|
||||
_, ok := params[string(k)]
|
||||
if !ok {
|
||||
params[string(k)] = make([]string, 0)
|
||||
}
|
||||
params[string(k)] = append(params[string(k)], string(v))
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -43,10 +43,7 @@ func (r *Request) IsTLS() bool {
|
||||
|
||||
// Scheme implements `engine.Request#Scheme` function.
|
||||
func (r *Request) Scheme() string {
|
||||
if r.IsTLS() {
|
||||
return "https"
|
||||
}
|
||||
return "http"
|
||||
return r.Request.URL.Scheme
|
||||
}
|
||||
|
||||
// Host implements `engine.Request#Host` function.
|
||||
|
Loading…
Reference in New Issue
Block a user