1
0
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:
Vishal Rana 2016-06-03 07:22:39 -07:00
commit 98a822e8d7
3 changed files with 17 additions and 9 deletions

View File

@ -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)
}
}
}

View File

@ -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
}

View File

@ -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.