From 04ad0e787aee45a3aae6722519aaac92b8ac6e86 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Thu, 19 Dec 2019 00:30:57 -0500 Subject: minor refactor of apiEndpointHandler(): reduced early returns removed unnecessary switch statement --- svc/handlers.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/svc/handlers.go b/svc/handlers.go index cf9d279..11f7633 100644 --- a/svc/handlers.go +++ b/svc/handlers.go @@ -114,9 +114,9 @@ func apiEndpointHandler(w http.ResponseWriter, r *http.Request) { err := apiEndpointQuery(w, r) if err != nil { errHTTP(w, r, err, http.StatusInternalServerError) - return + } else { + log200(r) } - log200(r) return } @@ -124,10 +124,7 @@ func apiEndpointHandler(w http.ResponseWriter, r *http.Request) { page := 1 pageVal := r.FormValue("page") - switch pageVal { - case "": - break - default: + if pageVal != "" { page, err = strconv.Atoi(pageVal) if err != nil || page < 1 { page = 1 @@ -157,9 +154,9 @@ func apiEndpointHandler(w http.ResponseWriter, r *http.Request) { _, err := w.Write([]byte(strings.TrimSpace("getwtxt " + Vers))) if err != nil { errHTTP(w, r, err, http.StatusInternalServerError) - return + } else { + log200(r) } - log200(r) return default: -- cgit 1.4.1-2-gfad0