From 41bd4759eb9fa6f5aa168069928df49b9953b0b8 Mon Sep 17 00:00:00 2001 From: Anders Pitman Date: Sat, 10 Oct 2020 08:20:17 -0600 Subject: [PATCH] Add ETag hash to tunnel responses --- api.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api.go b/api.go index 10c39a9..40e50e5 100644 --- a/api.go +++ b/api.go @@ -1,7 +1,9 @@ package main import ( + "crypto/md5" "encoding/json" + "fmt" "io" "net/http" ) @@ -52,6 +54,12 @@ func (a *Api) handleTunnels(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Error encoding tunnels")) return } + + hash := md5.Sum(body) + hashStr := fmt.Sprintf("%x", hash) + + w.Header()["ETag"] = []string{hashStr} + w.Write([]byte(body)) case "POST": a.validateSession(http.HandlerFunc(a.handleCreateTunnel)).ServeHTTP(w, r)