diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-26 01:48:12 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-26 02:05:59 -0400 |
commit | a6f47c07100be337f32325792990e58f5f4a3506 (patch) | |
tree | 309a35b47d4a900a9e02bc8bf48acb8296e10d93 /query.go | |
parent | e1e68aa2ba2992543603cfd5a4e1fa2e4eaeeb72 (diff) | |
download | getwtxt-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.go | 4 |
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 |