Skip to content

Commit

Permalink
Move to url.JoinPath
Browse files Browse the repository at this point in the history
  • Loading branch information
fredthomsen committed May 15, 2023
1 parent 9d68924 commit 0bab580
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions receiver/otlpreceiver/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"net"
"net/http"
"net/url"
"path/filepath"
"sync"

"go.uber.org/zap"
Expand Down Expand Up @@ -202,7 +201,8 @@ func (r *otlpReceiver) registerTraceConsumer(tc consumer.Traces) error {
r.tracesReceiver = trace.New(tc, r.obsrepGRPC)
httpTracesReceiver := trace.New(tc, r.obsrepHTTP)
if r.httpMux != nil {
urlPath := filepath.Join("/", url.PathEscape(r.cfg.HTTP.PathPrefix), "v1/traces")
u := url.URL{}
urlPath := u.JoinPath(url.PathEscape(r.cfg.HTTP.PathPrefix), "v1/traces").String()
r.httpMux.HandleFunc(urlPath, func(resp http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodPost {
handleUnmatchedMethod(resp)
Expand All @@ -228,7 +228,8 @@ func (r *otlpReceiver) registerMetricsConsumer(mc consumer.Metrics) error {
r.metricsReceiver = metrics.New(mc, r.obsrepGRPC)
httpMetricsReceiver := metrics.New(mc, r.obsrepHTTP)
if r.httpMux != nil {
urlPath := filepath.Join("/", url.PathEscape(r.cfg.HTTP.PathPrefix), "v1/metrics")
u := url.URL{}
urlPath := u.JoinPath(url.PathEscape(r.cfg.HTTP.PathPrefix), "v1/metrics").String()
r.httpMux.HandleFunc(urlPath, func(resp http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodPost {
handleUnmatchedMethod(resp)
Expand All @@ -254,7 +255,8 @@ func (r *otlpReceiver) registerLogsConsumer(lc consumer.Logs) error {
r.logsReceiver = logs.New(lc, r.obsrepGRPC)
httpLogsReceiver := logs.New(lc, r.obsrepHTTP)
if r.httpMux != nil {
urlPath := filepath.Join("/", url.PathEscape(r.cfg.HTTP.PathPrefix), "v1/logs")
u := url.URL{}
urlPath := u.JoinPath(url.PathEscape(r.cfg.HTTP.PathPrefix), "v1/logs").String()
r.httpMux.HandleFunc(urlPath, func(resp http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodPost {
handleUnmatchedMethod(resp)
Expand Down

0 comments on commit 0bab580

Please sign in to comment.