summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-12-19 00:30:57 -0500
committerBen Morrison <ben@gbmor.dev>2019-12-19 00:30:57 -0500
commit04ad0e787aee45a3aae6722519aaac92b8ac6e86 (patch)
treedcf27aff33f82da138713f6084544417273baed4 /svc
parent7ed96c765c55ef57c5f57286a7ad1ed7ba02d490 (diff)
downloadgetwtxt-04ad0e787aee45a3aae6722519aaac92b8ac6e86.tar.gz
minor refactor of apiEndpointHandler():
reduced early returns
removed unnecessary switch statement
Diffstat (limited to 'svc')
-rw-r--r--svc/handlers.go13
1 files 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: