Skip to content

Commit

Permalink
minor refactor of matchAndGet
Browse files Browse the repository at this point in the history
  • Loading branch information
bnkamalesh committed Nov 22, 2017
1 parent dd847a7 commit 658bbce
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,15 @@ func (r *Route) matchAndGet(requestURI string) (bool, map[string]string) {

// Getting URI parameters
values := r.uriPattern.FindStringSubmatch(requestURI)

var uriValues map[string]string
if len(values) > 0 {
uriValues = make(map[string]string, len(values)-1)
for j := 1; j < len(values); j++ {
uriValues[r.uriKeys[j-1]] = values[j]
uriValues := make(map[string]string, len(values)-1)
for i := 1; i < len(values); i++ {
uriValues[r.uriKeys[i-1]] = values[i]
}
return true, uriValues
}

return true, uriValues
return true, nil
}

// Router is the HTTP router
Expand Down

0 comments on commit 658bbce

Please sign in to comment.