Skip to content

Commit 7b814f4

Browse files
committed
Merge branch 'pgimalac/gorilla-mux-pr12' of github.com:DataDog/datadog-agent into pgimalac/gorilla-mux-pr12
2 parents 586db6f + 7133ca9 commit 7b814f4

74 files changed

Lines changed: 381 additions & 425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE-3rdparty.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,6 @@ core,github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/la
14501450
core,github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports,Apache-2.0,"Copyright 2012-2013 Rackspace, Inc | Copyright Gophercloud authors"
14511451
core,github.com/gophercloud/gophercloud/v2/openstack/utils,Apache-2.0,"Copyright 2012-2013 Rackspace, Inc | Copyright Gophercloud authors"
14521452
core,github.com/gophercloud/gophercloud/v2/pagination,Apache-2.0,"Copyright 2012-2013 Rackspace, Inc | Copyright Gophercloud authors"
1453-
core,github.com/gorilla/handlers,BSD-3-Clause,Copyright (c) 2023 The Gorilla Authors. All rights reserved
14541453
core,github.com/gorilla/mux,BSD-3-Clause,Copyright (c) 2023 The Gorilla Authors. All rights reserved
14551454
core,github.com/gorilla/websocket,BSD-2-Clause,Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved | Gary Burd <gary@beagledreams.com> | Google LLC (https://opensource.google.com/) | Joachim Bauch <mail@joachim-bauch.de>
14561455
core,github.com/gosnmp/gosnmp,BSD-2-Clause,Copyright 2012-2020 The GoSNMP Authors. All rights reserved.

cmd/agent/subcommands/run/internal/clcrunnerapi/clc_runner_server.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import (
1717
"net/http"
1818
"time"
1919

20-
"github.com/gorilla/mux"
21-
2220
v1 "github.com/DataDog/datadog-agent/cmd/agent/subcommands/run/internal/clcrunnerapi/v1"
2321
"github.com/DataDog/datadog-agent/comp/core/autodiscovery"
2422
ipc "github.com/DataDog/datadog-agent/comp/core/ipc/def"
@@ -33,18 +31,20 @@ var clcListener net.Listener
3331
// StartCLCRunnerServer creates the router and starts the HTTP server
3432
func StartCLCRunnerServer(extraHandlers map[string]http.Handler, ac autodiscovery.Component, ipc ipc.Component) error {
3533
// create the root HTTP router
36-
r := mux.NewRouter()
34+
mux := http.NewServeMux()
3735

3836
// IPC REST API server
39-
v1.SetupHandlers(r.PathPrefix("/api/v1").Subrouter(), ac)
37+
v1Mux := http.NewServeMux()
38+
v1.SetupHandlers(v1Mux, ac)
39+
mux.Handle("/api/v1/", http.StripPrefix("/api/v1", v1Mux))
4040

4141
// Register extra hanlders
4242
for path, handler := range extraHandlers {
43-
r.Handle(path, handler)
43+
mux.Handle(path, handler)
4444
}
4545

4646
// Validate token for every request
47-
r.Use(validateCLCRunnerToken)
47+
r := validateCLCRunnerToken(mux)
4848

4949
// get the transport we're going to use under HTTP
5050
var err error

cmd/agent/subcommands/run/internal/clcrunnerapi/v1/clcrunner.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"maps"
1414
"net/http"
1515

16-
"github.com/gorilla/mux"
17-
1816
"github.com/DataDog/datadog-agent/comp/core/autodiscovery"
1917
"github.com/DataDog/datadog-agent/pkg/api/version"
2018
checkid "github.com/DataDog/datadog-agent/pkg/collector/check/id"
@@ -32,12 +30,12 @@ import (
3230
// The API is only meant to expose stats used by the Cluster Agent
3331
// Check configs and any data that could contain sensitive information
3432
// MUST NEVER be sent via this API
35-
func SetupHandlers(r *mux.Router, ac autodiscovery.Component) {
36-
r.HandleFunc("/clcrunner/version", version.Get).Methods("GET")
37-
r.HandleFunc("/clcrunner/stats", func(w http.ResponseWriter, r *http.Request) {
33+
func SetupHandlers(r *http.ServeMux, ac autodiscovery.Component) {
34+
r.HandleFunc("GET /clcrunner/version", version.Get)
35+
r.HandleFunc("GET /clcrunner/stats", func(w http.ResponseWriter, r *http.Request) {
3836
getCLCRunnerStats(w, r, ac)
39-
}).Methods("GET")
40-
r.HandleFunc("/clcrunner/workers", getCLCRunnerWorkers).Methods("GET")
37+
})
38+
r.HandleFunc("GET /clcrunner/workers", getCLCRunnerWorkers)
4139
}
4240

4341
// getCLCRunnerStats retrieves Cluster Level Check runners stats

cmd/cluster-agent-cloudfoundry/subcommands/run/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"context"
1313
"errors"
1414
"fmt"
15+
"net/http"
1516
"os"
1617
"os/signal"
1718
"regexp"
@@ -20,7 +21,6 @@ import (
2021

2122
"code.cloudfoundry.org/bbs"
2223
"github.com/cloudfoundry-community/go-cfclient/v2"
23-
"github.com/gorilla/mux"
2424
"github.com/spf13/cobra"
2525

2626
"github.com/DataDog/datadog-agent/cmd/agent/common"
@@ -244,7 +244,7 @@ func run(
244244
var clusterCheckHandler *clusterchecksHandler.Handler
245245
clusterCheckHandler, err = setupClusterCheck(mainCtx, ac, taggerComp)
246246
if err == nil {
247-
api.ModifyAPIRouter(func(r *mux.Router) {
247+
api.ModifyAPIRouter(func(r *http.ServeMux) {
248248
dcav1.InstallChecksEndpoints(r, clusteragent.ServerContext{ClusterCheckHandler: clusterCheckHandler})
249249
})
250250

cmd/cluster-agent/api/agent/agent.go

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"io"
1414
"net/http"
1515

16-
"github.com/gorilla/mux"
17-
1816
"github.com/DataDog/datadog-agent/cmd/agent/common/signals"
1917
"github.com/DataDog/datadog-agent/comp/core/autodiscovery"
2018
diagnose "github.com/DataDog/datadog-agent/comp/core/diagnose/def"
@@ -40,32 +38,32 @@ import (
4038
)
4139

4240
// SetupHandlers adds the specific handlers for cluster agent endpoints
43-
func SetupHandlers(r *mux.Router, wmeta workloadmeta.Component, ac autodiscovery.Component, statusComponent status.Component, settings settings.Component, taggerComp tagger.Component, diagnoseComponent diagnose.Component, dcametadataComp dcametadata.Component, clusterChecksMetadataComp clusterchecksmetadata.Component, ipc ipc.Component) {
44-
r.HandleFunc("/version", getVersion).Methods("GET")
45-
r.HandleFunc("/hostname", getHostname).Methods("GET")
46-
r.HandleFunc("/flare", func(w http.ResponseWriter, r *http.Request) {
41+
func SetupHandlers(r *http.ServeMux, wmeta workloadmeta.Component, ac autodiscovery.Component, statusComponent status.Component, settings settings.Component, taggerComp tagger.Component, diagnoseComponent diagnose.Component, dcametadataComp dcametadata.Component, clusterChecksMetadataComp clusterchecksmetadata.Component, ipc ipc.Component) {
42+
r.HandleFunc("GET /version", getVersion)
43+
r.HandleFunc("GET /hostname", getHostname)
44+
r.HandleFunc("POST /flare", func(w http.ResponseWriter, r *http.Request) {
4745
makeFlare(w, r, statusComponent, diagnoseComponent, ipc)
48-
}).Methods("POST")
49-
r.HandleFunc("/stop", stopAgent).Methods("POST")
50-
r.HandleFunc("/status", func(w http.ResponseWriter, r *http.Request) { getStatus(w, r, statusComponent) }).Methods("GET")
51-
r.HandleFunc("/status/health", getHealth).Methods("GET")
52-
r.HandleFunc("/config-check", func(w http.ResponseWriter, r *http.Request) {
46+
})
47+
r.HandleFunc("POST /stop", stopAgent)
48+
r.HandleFunc("GET /status", func(w http.ResponseWriter, r *http.Request) { getStatus(w, r, statusComponent) })
49+
r.HandleFunc("GET /status/health", getHealth)
50+
r.HandleFunc("GET /config-check", func(w http.ResponseWriter, r *http.Request) {
5351
getConfigCheck(w, r, ac)
54-
}).Methods("GET")
55-
r.HandleFunc("/config", settings.GetFullConfig("")).Methods("GET")
56-
r.HandleFunc("/config/without-defaults", settings.GetFullConfigWithoutDefaults("")).Methods("GET")
57-
r.HandleFunc("/config/by-source", settings.GetFullConfigBySource()).Methods("GET")
58-
r.HandleFunc("/config/list-runtime", settings.ListConfigurable).Methods("GET")
59-
r.HandleFunc("/config/{setting}", settings.GetValue).Methods("GET")
60-
r.HandleFunc("/config/{setting}", settings.SetValue).Methods("POST")
61-
r.HandleFunc("/autoscaler-list", func(w http.ResponseWriter, r *http.Request) { getAutoscalerList(w, r) }).Methods("GET")
62-
r.HandleFunc("/local-autoscaling-check", func(w http.ResponseWriter, r *http.Request) { getLocalAutoscalingWorkloadCheck(w, r) }).Methods("GET")
63-
r.HandleFunc("/tagger-list", func(w http.ResponseWriter, r *http.Request) { getTaggerList(w, r, taggerComp) }).Methods("GET")
64-
r.HandleFunc("/workload-list", func(w http.ResponseWriter, r *http.Request) {
52+
})
53+
r.HandleFunc("GET /config", settings.GetFullConfig(""))
54+
r.HandleFunc("GET /config/without-defaults", settings.GetFullConfigWithoutDefaults(""))
55+
r.HandleFunc("GET /config/by-source", settings.GetFullConfigBySource())
56+
r.HandleFunc("GET /config/list-runtime", settings.ListConfigurable)
57+
r.HandleFunc("GET /config/{setting}", settings.GetValue)
58+
r.HandleFunc("POST /config/{setting}", settings.SetValue)
59+
r.HandleFunc("GET /autoscaler-list", func(w http.ResponseWriter, r *http.Request) { getAutoscalerList(w, r) })
60+
r.HandleFunc("GET /local-autoscaling-check", func(w http.ResponseWriter, r *http.Request) { getLocalAutoscalingWorkloadCheck(w, r) })
61+
r.HandleFunc("GET /tagger-list", func(w http.ResponseWriter, r *http.Request) { getTaggerList(w, r, taggerComp) })
62+
r.HandleFunc("GET /workload-list", func(w http.ResponseWriter, r *http.Request) {
6563
getWorkloadList(w, r, wmeta)
66-
}).Methods("GET")
67-
r.HandleFunc("/metadata/cluster-agent", dcametadataComp.WritePayloadAsJSON).Methods("GET")
68-
r.HandleFunc("/metadata/cluster-checks", clusterChecksMetadataComp.WritePayloadAsJSON).Methods("GET")
64+
})
65+
r.HandleFunc("GET /metadata/cluster-agent", dcametadataComp.WritePayloadAsJSON)
66+
r.HandleFunc("GET /metadata/cluster-checks", clusterChecksMetadataComp.WritePayloadAsJSON)
6967

7068
// Special handler to compute running agent Code coverage
7169
coverage.SetupCoverageHandler(r)

cmd/cluster-agent/api/server.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import (
2222
"strings"
2323
"time"
2424

25-
"github.com/gorilla/handlers"
26-
"github.com/gorilla/mux"
2725
grpc_auth "github.com/grpc-ecosystem/go-grpc-middleware/auth"
2826
"google.golang.org/grpc"
2927

@@ -44,6 +42,7 @@ import (
4442
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
4543
dcametadata "github.com/DataDog/datadog-agent/comp/metadata/clusteragent/def"
4644
clusterchecksmetadata "github.com/DataDog/datadog-agent/comp/metadata/clusterchecks/def"
45+
apiMiddleware "github.com/DataDog/datadog-agent/pkg/api/middleware"
4746

4847
"github.com/DataDog/datadog-agent/pkg/api/util"
4948
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
@@ -55,15 +54,16 @@ import (
5554

5655
var (
5756
listener net.Listener
58-
router *mux.Router
59-
apiRouter *mux.Router
57+
router *http.ServeMux
58+
apiRouter *http.ServeMux
6059
)
6160

6261
// StartServer creates the router and starts the HTTP server
6362
func StartServer(ctx context.Context, w workloadmeta.Component, taggerComp tagger.Component, ac autodiscovery.Component, statusComponent status.Component, settings settings.Component, cfg config.Component, ipc ipc.Component, diagnoseComponent diagnose.Component, dcametadataComp dcametadata.Component, clusterChecksMetadataComp clusterchecksmetadata.Component, telemetry telemetry.Component) error {
6463
// create the root HTTP router
65-
router = mux.NewRouter()
66-
apiRouter = router.PathPrefix("/api/v1").Subrouter()
64+
router = http.NewServeMux()
65+
apiRouter = http.NewServeMux()
66+
router.Handle("/api/v1/", http.StripPrefix("/api/v1", apiRouter))
6767

6868
// IPC REST API server
6969
agent.SetupHandlers(router, w, ac, statusComponent, settings, taggerComp, diagnoseComponent, dcametadataComp, clusterChecksMetadataComp, ipc)
@@ -75,11 +75,12 @@ func StartServer(ctx context.Context, w workloadmeta.Component, taggerComp tagge
7575
languagedetection.InstallLanguageDetectionEndpoints(ctx, apiRouter, w, cfg)
7676

7777
// API V2 Series APIs
78-
v2ApiRouter := router.PathPrefix("/api/v2").Subrouter()
78+
v2ApiRouter := http.NewServeMux()
79+
router.Handle("/api/v2/", http.StripPrefix("/api/v2", v2ApiRouter))
7980
series.InstallNodeMetricsEndpoints(ctx, v2ApiRouter, cfg)
8081

8182
// Validate token for every request
82-
router.Use(validateToken(ipc))
83+
httpHandler := validateToken(ipc)(router)
8384

8485
// get the transport we're going to use under HTTP
8586
var err error
@@ -139,10 +140,7 @@ func StartServer(ctx context.Context, w workloadmeta.Component, taggerComp tagge
139140
grpcSrv,
140141
// Use a recovery handler to log panics if they happen.
141142
// The client will receive a 500 error.
142-
handlers.RecoveryHandler(
143-
handlers.PrintRecoveryStack(true),
144-
handlers.RecoveryLogger(errorLog),
145-
)(router),
143+
apiMiddleware.RecoveryHandler(errorLog)(httpHandler),
146144
timeout,
147145
)
148146
srv.ErrorLog = errorLog
@@ -154,12 +152,12 @@ func StartServer(ctx context.Context, w workloadmeta.Component, taggerComp tagge
154152
}
155153

156154
// ModifyAPIRouter allows to pass in a function to modify router used in server
157-
func ModifyAPIRouter(f func(*mux.Router)) {
155+
func ModifyAPIRouter(f func(*http.ServeMux)) {
158156
f(apiRouter)
159157
}
160158

161159
// ModifyRootRouter allows to pass in a function to modify the root router used in server
162-
func ModifyRootRouter(f func(*mux.Router)) {
160+
func ModifyRootRouter(f func(*http.ServeMux)) {
163161
f(router)
164162
}
165163

@@ -173,7 +171,7 @@ func StopServer() {
173171

174172
// We only want to maintain 1 API and expose an external route to serve the cluster level metadata.
175173
// As we have 2 different tokens for the validation, we need to validate accordingly.
176-
func validateToken(ipc ipc.Component) mux.MiddlewareFunc {
174+
func validateToken(ipc ipc.Component) func(http.Handler) http.Handler {
177175
dcaTokenValidator := util.TokenValidator(util.GetDCAAuthToken)
178176
localTokenGetter := util.TokenValidator(ipc.GetAuthToken)
179177

cmd/cluster-agent/api/v1/cloudfoundry_metadata.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import (
1111
"encoding/json"
1212
"net/http"
1313

14-
"github.com/gorilla/mux"
15-
1614
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
1715
"github.com/DataDog/datadog-agent/pkg/clusteragent/api"
1816
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
@@ -34,7 +32,7 @@ func NewCloudFoundryMetadataHandler(bbsCache cloudfoundry.BBSCacheI, ccCache clo
3432
}
3533
}
3634

37-
func installCloudFoundryMetadataEndpoints(r *mux.Router) {
35+
func installCloudFoundryMetadataEndpoints(r *http.ServeMux) {
3836
// Get the Cloud Foundry caches for the metadata handlers
3937
bbsCache, err := cloudfoundry.GetGlobalBBSCache()
4038
if err != nil {
@@ -47,23 +45,22 @@ func installCloudFoundryMetadataEndpoints(r *mux.Router) {
4745

4846
handler := NewCloudFoundryMetadataHandler(bbsCache, ccCache)
4947

50-
r.HandleFunc("/tags/cf/apps/{nodeName}", api.WithTelemetryWrapper("getCFAppsMetadataForNode", handler.getCFAppsMetadataForNode)).Methods("GET")
48+
r.HandleFunc("GET /tags/cf/apps/{nodeName}", api.WithTelemetryWrapper("getCFAppsMetadataForNode", handler.getCFAppsMetadataForNode))
5149

5250
if pkgconfigsetup.Datadog().GetBool("cluster_agent.serve_nozzle_data") {
53-
r.HandleFunc("/cf/apps/{guid}", api.WithTelemetryWrapper("getCFApplication", handler.getCFApplication)).Methods("GET")
54-
r.HandleFunc("/cf/apps", api.WithTelemetryWrapper("getCFApplications", handler.getCFApplications)).Methods("GET")
55-
r.HandleFunc("/cf/org_quotas", api.WithTelemetryWrapper("getCFOrgQuotas", handler.getCFOrgQuotas)).Methods("GET")
56-
r.HandleFunc("/cf/orgs", api.WithTelemetryWrapper("getCFOrgs", handler.getCFOrgs)).Methods("GET")
51+
r.HandleFunc("GET /cf/apps/{guid}", api.WithTelemetryWrapper("getCFApplication", handler.getCFApplication))
52+
r.HandleFunc("GET /cf/apps", api.WithTelemetryWrapper("getCFApplications", handler.getCFApplications))
53+
r.HandleFunc("GET /cf/org_quotas", api.WithTelemetryWrapper("getCFOrgQuotas", handler.getCFOrgQuotas))
54+
r.HandleFunc("GET /cf/orgs", api.WithTelemetryWrapper("getCFOrgs", handler.getCFOrgs))
5755
}
5856
}
5957

60-
func installKubernetesMetadataEndpoints(r *mux.Router, w workloadmeta.Component) {}
58+
func installKubernetesMetadataEndpoints(r *http.ServeMux, w workloadmeta.Component) {}
6159

6260
// getCFAppsMetadataForNode is only used when the node agent hits the DCA for the list of cloudfoundry applications tags
6361
// It return a list of tags for each application that can be directly used in the tagger
6462
func (h *CloudFoundryMetadataHandler) getCFAppsMetadataForNode(w http.ResponseWriter, r *http.Request) {
65-
vars := mux.Vars(r)
66-
nodename := vars["nodeName"]
63+
nodename := r.PathValue("nodeName")
6764

6865
if h.bbsCache == nil {
6966
log.Errorf("BBS cache is not initialized")
@@ -123,8 +120,7 @@ func (h *CloudFoundryMetadataHandler) getCFApplications(w http.ResponseWriter, r
123120
// getCFApplication is only used when the PCF firehose nozzle hits the DCA for a single cloudfoundry application
124121
// It return a single CFApplication with the given guid
125122
func (h *CloudFoundryMetadataHandler) getCFApplication(w http.ResponseWriter, r *http.Request) {
126-
vars := mux.Vars(r)
127-
guid := vars["guid"]
123+
guid := r.PathValue("guid")
128124

129125
if h.ccCache == nil {
130126
log.Errorf("CC cache is not initialized")

cmd/cluster-agent/api/v1/cloudfoundry_metadata_nocompile.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
package v1
99

1010
import (
11+
"net/http"
12+
1113
workloadmeta "github.com/DataDog/datadog-agent/comp/core/workloadmeta/def"
12-
"github.com/gorilla/mux"
1314
)
1415

15-
func installCloudFoundryMetadataEndpoints(_ *mux.Router) {}
16+
func installCloudFoundryMetadataEndpoints(_ *http.ServeMux) {}
1617

17-
func installKubernetesMetadataEndpoints(_ *mux.Router, _ workloadmeta.Component) {}
18+
func installKubernetesMetadataEndpoints(_ *http.ServeMux, _ workloadmeta.Component) {}

cmd/cluster-agent/api/v1/clusterchecks.go

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"net"
1414
"net/http"
1515

16-
"github.com/gorilla/mux"
17-
1816
"github.com/DataDog/datadog-agent/pkg/clusteragent"
1917
"github.com/DataDog/datadog-agent/pkg/clusteragent/api"
2018
cctypes "github.com/DataDog/datadog-agent/pkg/clusteragent/clusterchecks/types"
@@ -23,12 +21,12 @@ import (
2321
)
2422

2523
// Install registers v1 API endpoints
26-
func installClusterCheckEndpoints(r *mux.Router, sc clusteragent.ServerContext) {
27-
r.HandleFunc("/clusterchecks/status/{identifier}", api.WithTelemetryWrapper("postCheckStatus", postCheckStatus(sc))).Methods("POST")
28-
r.HandleFunc("/clusterchecks/configs/{identifier}", api.WithTelemetryWrapper("getCheckConfigs", getCheckConfigs(sc))).Methods("GET")
29-
r.HandleFunc("/clusterchecks/rebalance", api.WithTelemetryWrapper("postRebalanceChecks", postRebalanceChecks(sc))).Methods("POST")
30-
r.HandleFunc("/clusterchecks", api.WithTelemetryWrapper("getState", getState(sc))).Methods("GET")
31-
r.HandleFunc("/clusterchecks/isolate/check/{identifier}", api.WithTelemetryWrapper("postIsolateCheck", postIsolateCheck(sc))).Methods("POST")
24+
func installClusterCheckEndpoints(r *http.ServeMux, sc clusteragent.ServerContext) {
25+
r.HandleFunc("POST /clusterchecks/status/{identifier}", api.WithTelemetryWrapper("postCheckStatus", postCheckStatus(sc)))
26+
r.HandleFunc("GET /clusterchecks/configs/{identifier}", api.WithTelemetryWrapper("getCheckConfigs", getCheckConfigs(sc)))
27+
r.HandleFunc("POST /clusterchecks/rebalance", api.WithTelemetryWrapper("postRebalanceChecks", postRebalanceChecks(sc)))
28+
r.HandleFunc("GET /clusterchecks", api.WithTelemetryWrapper("getState", getState(sc)))
29+
r.HandleFunc("POST /clusterchecks/isolate/check/{identifier}", api.WithTelemetryWrapper("postIsolateCheck", postIsolateCheck(sc)))
3230
}
3331

3432
// RebalancePostPayload struct is for the JSON messages received from a client POST request
@@ -47,8 +45,7 @@ func postCheckStatus(sc clusteragent.ServerContext) func(w http.ResponseWriter,
4745
return
4846
}
4947

50-
vars := mux.Vars(r)
51-
identifier := vars["identifier"]
48+
identifier := r.PathValue("identifier")
5249

5350
decoder := json.NewDecoder(r.Body)
5451
var status cctypes.NodeStatus
@@ -80,8 +77,7 @@ func getCheckConfigs(sc clusteragent.ServerContext) func(w http.ResponseWriter,
8077
return
8178
}
8279

83-
vars := mux.Vars(r)
84-
identifier := vars["identifier"]
80+
identifier := r.PathValue("identifier")
8581
response, err := sc.ClusterCheckHandler.GetConfigs(identifier)
8682
if err != nil {
8783
http.Error(w, err.Error(), http.StatusInternalServerError)
@@ -132,8 +128,7 @@ func postIsolateCheck(sc clusteragent.ServerContext) func(w http.ResponseWriter,
132128
return
133129
}
134130

135-
vars := mux.Vars(r)
136-
isolateCheckID := vars["identifier"]
131+
isolateCheckID := r.PathValue("identifier")
137132

138133
response := sc.ClusterCheckHandler.IsolateCheck(isolateCheckID)
139134

cmd/cluster-agent/api/v1/clusterchecks_nocompile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
package v1
99

1010
import (
11-
"github.com/gorilla/mux"
11+
"net/http"
1212

1313
"github.com/DataDog/datadog-agent/pkg/clusteragent"
1414
)
1515

1616
// installClusterCheckEndpoints not implemented
17-
func installClusterCheckEndpoints(_ *mux.Router, _ clusteragent.ServerContext) {}
17+
func installClusterCheckEndpoints(_ *http.ServeMux, _ clusteragent.ServerContext) {}

0 commit comments

Comments
 (0)