summary refs log tree commit diff stats
path: root/svc/handlers.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-12 21:35:52 -0400
committerGitHub <noreply@github.com>2019-06-12 21:35:52 -0400
commita2d5115725dea018edb8a8dbaf3c622fabe2680e (patch)
treecacbd836373239b0b3f5b8ce25fc642ce43179a6 /svc/handlers.go
parentbe76daaa8b4e6f6d5f60c79ecd84a8d034cbe351 (diff)
parentfbfe7f582979c9db9089187b7316013bd0b1d423 (diff)
downloadgetwtxt-a2d5115725dea018edb8a8dbaf3c622fabe2680e.tar.gz
Merge pull request #8 from getwtxt/multiple-logfiles
Using separate log files for requests and other messages
Diffstat (limited to 'svc/handlers.go')
-rw-r--r--svc/handlers.go14
1 files changed, 4 insertions, 10 deletions
diff --git a/svc/handlers.go b/svc/handlers.go
index def01ad..924b487 100644
--- a/svc/handlers.go
+++ b/svc/handlers.go
@@ -42,12 +42,10 @@ func servStatic(w http.ResponseWriter, isCSS bool) error {
 // handles "/" and "/css"
 func staticHandler(w http.ResponseWriter, r *http.Request) {
 	isCSS := strings.Contains(r.URL.Path, "css")
-
 	if err := servStatic(w, isCSS); err != nil {
 		errHTTP(w, r, err, http.StatusInternalServerError)
 		return
 	}
-
 	log200(r)
 }
 
@@ -69,17 +67,15 @@ func apiAllTweetsHandler(w http.ResponseWriter, r *http.Request) {
 	}
 
 	data := parseQueryOut(out)
-
 	etag := fmt.Sprintf("%x", sha256.Sum256(data))
+
 	w.Header().Set("ETag", etag)
 	w.Header().Set("Content-Type", txtutf8)
-
 	_, err = w.Write(data)
 	if err != nil {
 		errHTTP(w, r, err, http.StatusInternalServerError)
 		return
 	}
-
 	log200(r)
 }
 
@@ -134,8 +130,8 @@ func apiEndpointHandler(w http.ResponseWriter, r *http.Request) {
 	errLog("", err)
 
 	data := parseQueryOut(out)
-
 	etag := fmt.Sprintf("%x", sha256.Sum256(data))
+
 	w.Header().Set("ETag", etag)
 	w.Header().Set("Content-Type", txtutf8)
 
@@ -162,8 +158,8 @@ func apiTagsBaseHandler(w http.ResponseWriter, r *http.Request) {
 
 	out = registry.ReduceToPage(1, out)
 	data := parseQueryOut(out)
-
 	etag := fmt.Sprintf("%x", sha256.Sum256(data))
+
 	w.Header().Set("ETag", etag)
 	w.Header().Set("Content-Type", txtutf8)
 
@@ -172,7 +168,6 @@ func apiTagsBaseHandler(w http.ResponseWriter, r *http.Request) {
 		errHTTP(w, r, err, http.StatusInternalServerError)
 		return
 	}
-
 	log200(r)
 }
 
@@ -184,8 +179,8 @@ func apiTagsHandler(w http.ResponseWriter, r *http.Request) {
 	out := compositeStatusQuery("#"+tags, r)
 	out = registry.ReduceToPage(1, out)
 	data := parseQueryOut(out)
-
 	etag := fmt.Sprintf("%x", sha256.Sum256(data))
+
 	w.Header().Set("ETag", etag)
 	w.Header().Set("Content-Type", txtutf8)
 
@@ -194,6 +189,5 @@ func apiTagsHandler(w http.ResponseWriter, r *http.Request) {
 		errHTTP(w, r, err, http.StatusInternalServerError)
 		return
 	}
-
 	log200(r)
 }