diff --git a/cmd/collector/app/http_handler.go b/cmd/collector/app/http_handler.go index de30edaa621..1869a4c7816 100644 --- a/cmd/collector/app/http_handler.go +++ b/cmd/collector/app/http_handler.go @@ -55,10 +55,11 @@ func NewAPIHandler( // RegisterRoutes registers routes for this handler on the given router func (aH *APIHandler) RegisterRoutes(router *mux.Router) { - router.HandleFunc("/api/traces", aH.saveSpan).Methods(http.MethodPost) + router.HandleFunc("/api/traces", aH.SaveSpan).Methods(http.MethodPost) } -func (aH *APIHandler) saveSpan(w http.ResponseWriter, r *http.Request) { +// SaveSpan submits the span provided in the request body to the JaegerBatchesHandler +func (aH *APIHandler) SaveSpan(w http.ResponseWriter, r *http.Request) { bodyBytes, err := ioutil.ReadAll(r.Body) r.Body.Close() if err != nil { diff --git a/cmd/collector/app/http_handler_test.go b/cmd/collector/app/http_handler_test.go index c5d5e8c833a..82106012e90 100644 --- a/cmd/collector/app/http_handler_test.go +++ b/cmd/collector/app/http_handler_test.go @@ -162,7 +162,7 @@ func TestCannotReadBodyFromRequest(t *testing.T) { req, err := http.NewRequest(http.MethodPost, "whatever", &errReader{}) assert.NoError(t, err) rw := dummyResponseWriter{} - handler.saveSpan(&rw, req) + handler.SaveSpan(&rw, req) assert.EqualValues(t, http.StatusInternalServerError, rw.myStatusCode) assert.EqualValues(t, "Unable to process request body: Simulated error reading body\n", rw.myBody) }