summary refs log tree commit diff stats
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
parent7ed96c765c55ef57c5f57286a7ad1ed7ba02d490 (diff)
downloadgetwtxt-04ad0e787aee45a3aae6722519aaac92b8ac6e86.tar.gz
minor refactor of apiEndpointHandler():
reduced early returns
removed unnecessary switch statement
-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:
on <ben@gbmor.dev> 2019-06-04 22:56:28 -0400 committer Ben Morrison <ben@gbmor.dev> 2019-06-05 00:12:49 -0400 cli flags for db path/type, assets dir. systemd unit file. makefile.' href='/gbmor/getwtxt/commit/Makefile?h=v0.4.2&id=69217dd27196dd59c96bc405afe4bfd83ad17c00'>69217dd ^
96fbc6e ^



be76daa ^
69217dd ^
96fbc6e ^
69217dd ^
96fbc6e ^


69217dd ^
be76daa ^

69217dd ^
96fbc6e ^
69217dd ^
96fbc6e ^



69217dd ^
96fbc6e ^


ee0d421 ^
96fbc6e ^

69217dd ^






96fbc6e ^


69217dd ^
96fbc6e ^
be76daa ^

69217dd ^
96fbc6e ^
69217dd ^
96fbc6e ^











69217dd ^

96fbc6e ^



be76daa ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80