Skip to content

Commit

Permalink
Merge pull request #1723 from weaveworks/name-routes
Browse files Browse the repository at this point in the history
Name our routes, so /metrics gives more sensible aggregations
  • Loading branch information
paulbellamy authored Jul 26, 2016
2 parents 2132528 + 2741584 commit 683727e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
9 changes: 7 additions & 2 deletions app/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ import (

// RegisterControlRoutes registers the various control routes with a http mux.
func RegisterControlRoutes(router *mux.Router, cr ControlRouter) {
router.Methods("GET").Path("/api/control/ws").
router.
Methods("GET").
Path("/api/control/ws").
HandlerFunc(requestContextDecorator(handleProbeWS(cr)))
router.Methods("POST").MatcherFunc(URLMatcher("/api/control/{probeID}/{nodeID}/{control}")).
router.
Methods("POST").
Name("api_control_probeid_nodeid_control").
MatcherFunc(URLMatcher("/api/control/{probeID}/{nodeID}/{control}")).
HandlerFunc(requestContextDecorator(handleControl(cr)))
}

Expand Down
4 changes: 4 additions & 0 deletions app/pipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ import (
// RegisterPipeRoutes registers the pipe routes
func RegisterPipeRoutes(router *mux.Router, pr PipeRouter) {
router.Methods("GET").
Name("api_pipe_pipeid_check").
Path("/api/pipe/{pipeID}/check").
HandlerFunc(requestContextDecorator(checkPipe(pr, UIEnd)))

router.Methods("GET").
Name("api_pipe_pipeid").
Path("/api/pipe/{pipeID}").
HandlerFunc(requestContextDecorator(handlePipeWs(pr, UIEnd)))

router.Methods("GET").
Name("api_pipe_pipeid_probe").
Path("/api/pipe/{pipeID}/probe").
HandlerFunc(requestContextDecorator(handlePipeWs(pr, ProbeEnd)))

router.Methods("DELETE", "POST").
Name("api_pipe_pipeid").
Path("/api/pipe/{pipeID}").
HandlerFunc(requestContextDecorator(deletePipe(pr)))
}
Expand Down
18 changes: 12 additions & 6 deletions app/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,18 @@ func RegisterTopologyRoutes(router *mux.Router, r Reporter) {
gzipHandler(requestContextDecorator(apiHandler(r))))
get.HandleFunc("/api/topology",
gzipHandler(requestContextDecorator(topologyRegistry.makeTopologyList(r))))
get.HandleFunc("/api/topology/{topology}",
gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleTopology))))
get.HandleFunc("/api/topology/{topology}/ws",
requestContextDecorator(captureReporter(r, handleWebsocket))) // NB not gzip!
get.MatcherFunc(URLMatcher("/api/topology/{topology}/{id}")).HandlerFunc(
gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleNode))))
get.
HandleFunc("/api/topology/{topology}",
gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleTopology)))).
Name("api_topology_topology")
get.
HandleFunc("/api/topology/{topology}/ws",
requestContextDecorator(captureReporter(r, handleWebsocket))). // NB not gzip!
Name("api_topology_topology_ws")
get.
MatcherFunc(URLMatcher("/api/topology/{topology}/{id}")).HandlerFunc(
gzipHandler(requestContextDecorator(topologyRegistry.captureRenderer(r, handleNode)))).
Name("api_topology_topology_id")
get.HandleFunc("/api/report",
gzipHandler(requestContextDecorator(makeRawReportHandler(r))))
get.HandleFunc("/api/probes",
Expand Down

0 comments on commit 683727e

Please sign in to comment.