From 9452a37b2a917312fd356c574288459c7f0350c0 Mon Sep 17 00:00:00 2001 From: agerho000 Date: Mon, 30 Nov 2020 05:28:26 +0000 Subject: [PATCH] updated method naming --- handlers/handlers.go | 2 +- handlers/routes.go | 11 ++++++----- handlers/services.go | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/handlers/handlers.go b/handlers/handlers.go index 1f0ef42d..57c8e2d9 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -213,7 +213,7 @@ func returnJson(d interface{}, w http.ResponseWriter, r *http.Request) { json.NewEncoder(w).Encode(d) } -func returnResponseCode(s *services.Service, w http.ResponseWriter, r *http.Request) { +func returnLastResponse(s *services.Service, w http.ResponseWriter, r *http.Request) { // Go does not currently // support sending user-defined 1xx informational headers, // with the exception of 100-continue response header that the diff --git a/handlers/routes.go b/handlers/routes.go index 296a4391..9dd01c6f 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -1,15 +1,16 @@ package handlers import ( + "net/http" + "net/http/pprof" + "time" + sentryhttp "github.com/getsentry/sentry-go/http" "github.com/gorilla/mux" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/statping/statping/source" "github.com/statping/statping/types/core" "github.com/statping/statping/utils" - "net/http" - "net/http/pprof" - "time" _ "github.com/statping/statping/types/metrics" ) @@ -137,8 +138,8 @@ func Router() *mux.Router { api.Handle("/api/services/{id}/failures", authenticated(servicesDeleteFailuresHandler, false)).Methods("DELETE") api.Handle("/api/services/{id}/hits", scoped(apiServiceHitsHandler)).Methods("GET") api.Handle("/api/services/{id}/hits", authenticated(apiServiceHitsDeleteHandler, false)).Methods("DELETE") - api.Handle("/api/services/{id}/responsecode", authenticated(apiServiceResponseCodeHandler, false)).Methods("GET") - + api.Handle("/api/services/{id}/lastresponse", authenticated(apiServiceLastResponseHandler, false)).Methods("GET") + // API SERVICE CHART DATA Routes api.Handle("/api/services/{id}/hits_data", cached("30s", "application/json", apiServiceDataHandler)).Methods("GET") api.Handle("/api/services/{id}/failure_data", cached("30s", "application/json", apiServiceFailureDataHandler)).Methods("GET") diff --git a/handlers/services.go b/handlers/services.go index 5fcd2a6a..f73f8887 100644 --- a/handlers/services.go +++ b/handlers/services.go @@ -318,7 +318,7 @@ func apiServiceHitsHandler(r *http.Request) interface{} { return hts } -func apiServiceResponseCodeHandler(w http.ResponseWriter, r *http.Request) { +func apiServiceLastResponseHandler(w http.ResponseWriter, r *http.Request) { service, err := findService(r) if err != nil { @@ -326,5 +326,5 @@ func apiServiceResponseCodeHandler(w http.ResponseWriter, r *http.Request) { return } - returnResponseCode(service, w, r) + returnLastResponse(service, w, r) }