Skip to content

Commit c4d5c6c

Browse files
committed
fix golang critics
1 parent 64ae2ba commit c4d5c6c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pkg/snclient/listen_managedexporter.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ func (l *HandlerManagedExporter) Init(snc *Agent, conf *ConfigSection, _ *Config
154154
}
155155

156156
l.proxy = &httputil.ReverseProxy{
157-
Rewrite: func(pr *httputil.ProxyRequest) {
157+
Rewrite: func(proxyReq *httputil.ProxyRequest) {
158158
prefix := strings.TrimSuffix(l.urlPrefix, "/")
159-
proxyUrl := "http://" + l.agentAddress + strings.TrimPrefix(pr.In.URL.Path, prefix)
160-
if len(pr.In.URL.Query()) > 0 {
161-
proxyUrl = proxyUrl + "?" + pr.In.URL.Query().Encode()
159+
proxyURL := "http://" + l.agentAddress + strings.TrimPrefix(proxyReq.In.URL.Path, prefix)
160+
if len(proxyReq.In.URL.Query()) > 0 {
161+
proxyURL = proxyURL + "?" + proxyReq.In.URL.Query().Encode()
162162
}
163-
uri, _ := url.Parse(proxyUrl)
164-
pr.Out.URL = uri
163+
uri, _ := url.Parse(proxyURL)
164+
proxyReq.Out.URL = uri
165165
},
166166
ErrorHandler: getReverseProxyErrorHandlerFunc(l.Type()),
167167
}
@@ -188,9 +188,8 @@ func (l *HandlerManagedExporter) CheckPassword(req *http.Request, _ URLMapping)
188188
}
189189

190190
func (l *HandlerManagedExporter) GetMappings(*Agent) []URLMapping {
191-
prefix := strings.TrimSuffix(l.urlPrefix, "/")
192191
return []URLMapping{
193-
{URL: prefix + "/*", Handler: l.proxy},
192+
{URL: strings.TrimSuffix(l.urlPrefix, "/") + "/*", Handler: l.proxy},
194193
}
195194
}
196195

0 commit comments

Comments
 (0)