BlueGit

timfa bluegit

fix: houd één writeJSON voor de API

De issue-API declareerde writeJSON opnieuw. De gedeelde helper zet nu ook Cache-Control.

Co-authored-by: tim <tim@timfalken.com>

timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa

Authored 2026-10-23 · 3 weeks ago

Hash
a3dee03dff60e4dd87c1a01551a95726ac06321f
Parent
f3222d5f
2 files changed +1 −7
internal/server/api_http.go +1 −0
@@ -145,6 +145,7 @@ func writeJSON(w http.ResponseWriter, status int, v any) {
145 145 return
146 146 }
147 147 w.Header().Set("Content-Type", "application/json; charset=utf-8")
148 w.Header().Set("Cache-Control", "no-store")
148 149 w.WriteHeader(status)
149 150 _ = json.NewEncoder(w).Encode(v)
150 151 }
@@ -145,6 +145,7 @@ func writeJSON(w http.ResponseWriter, status int, v any) {
145 return
145 return
146 }
146 }
147 w.Header().Set("Content-Type", "application/json; charset=utf-8")
147 w.Header().Set("Content-Type", "application/json; charset=utf-8")
148 w.Header().Set("Cache-Control", "no-store")
148 w.WriteHeader(status)
149 w.WriteHeader(status)
149 _ = json.NewEncoder(w).Encode(v)
150 _ = json.NewEncoder(w).Encode(v)
150}
151}
internal/server/issues_api.go +0 −7
@@ -440,13 +440,6 @@ func (s *Server) issueJSON(repo store.Repo, iss store.Issue, notes []store.Issue
440 440 return obj
441 441 }
442 442
443 func writeJSON(w http.ResponseWriter, status int, v any) {
444 w.Header().Set("Content-Type", "application/json; charset=utf-8")
445 w.Header().Set("Cache-Control", "no-store")
446 w.WriteHeader(status)
447 _ = json.NewEncoder(w).Encode(v)
448 }
449
450 443 func nonNil(s []string) []string {
451 444 if s == nil {
452 445 return []string{}
@@ -440,13 +440,6 @@ func (s *Server) issueJSON(repo store.Repo, iss store.Issue, notes []store.Issue
440 return obj
440 return obj
441}
441}
442
442
443func writeJSON(w http.ResponseWriter, status int, v any) {
444 w.Header().Set("Content-Type", "application/json; charset=utf-8")
445 w.Header().Set("Cache-Control", "no-store")
446 w.WriteHeader(status)
447 _ = json.NewEncoder(w).Encode(v)
448}
449
450func nonNil(s []string) []string {
443func nonNil(s []string) []string {
451 if s == nil {
444 if s == nil {
452 return []string{}
445 return []string{}