summary refs log tree commit diff stats
path: root/query.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-26 01:48:12 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-26 02:05:59 -0400
commita6f47c07100be337f32325792990e58f5f4a3506 (patch)
tree309a35b47d4a900a9e02bc8bf48acb8296e10d93 /query.go
parente1e68aa2ba2992543603cfd5a4e1fa2e4eaeeb72 (diff)
downloadgetwtxt-a6f47c07100be337f32325792990e58f5f4a3506.tar.gz
simplified indexHandler to reference staticCache
sending ETag with all GET responses: sha256 of raw bytes
Diffstat (limited to 'query.go')
-rw-r--r--query.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/query.go b/query.go
index 63e203c..17d7a36 100644
--- a/query.go
+++ b/query.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+	"crypto/sha256"
 	"fmt"
 	"log"
 	"net/http"
@@ -107,7 +108,10 @@ func apiEndpointQuery(w http.ResponseWriter, r *http.Request) error {
 
 	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)
 
 	return err