Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #594 from danielscottt/issue-534
Browse files Browse the repository at this point in the history
fix #534: panic on metric tree lookup with trailing slash
  • Loading branch information
pittma committed Dec 4, 2015
2 parents be3ab11 + 7207c44 commit ef027e5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mgmt/rest/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,18 @@ func (s *Server) getMetrics(w http.ResponseWriter, r *http.Request, _ httprouter
}

func (s *Server) getMetricsFromTree(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
ns := parseNamespace(params.ByName("namespace"))
namespace := params.ByName("namespace")

// we land here if the request contains a trailing slash, because it matches the tree
// lookup URL: /v1/metrics/*namespace. If the length of the namespace param is 1, we
// redirect the request to getMetrics. This results in GET /v1/metrics and
// GET /v1/metrics/ behaving the same way.
if len(namespace) <= 1 {
s.getMetrics(w, r, params)
return
}

ns := parseNamespace(namespace)

var (
ver int
Expand Down

0 comments on commit ef027e5

Please sign in to comment.