fix(api): explicitly disable caching on api responses

This commit is contained in:
Gabe Kangas 2023-06-05 08:51:49 -07:00
parent 3ed5a0b7f3
commit af82d05421
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
2 changed files with 4 additions and 2 deletions

View File

@ -69,7 +69,6 @@ func GetExternalAPIUsers(w http.ResponseWriter, r *http.Request) {
controllers.InternalErrorHandler(w, err) controllers.InternalErrorHandler(w, err)
return return
} }
controllers.WriteResponse(w, tokens) controllers.WriteResponse(w, tokens)
} }

View File

@ -5,6 +5,7 @@ import (
"net/http" "net/http"
"github.com/owncast/owncast/models" "github.com/owncast/owncast/models"
"github.com/owncast/owncast/router/middleware"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@ -55,9 +56,11 @@ func WriteSimpleResponse(w http.ResponseWriter, success bool, message string) {
} }
} }
// WriteResponse will return an object as a JSON encoded response. // WriteResponse will return an object as a JSON encoded uncacheable response.
func WriteResponse(w http.ResponseWriter, response interface{}) { func WriteResponse(w http.ResponseWriter, response interface{}) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
middleware.DisableCache(w)
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
if err := json.NewEncoder(w).Encode(response); err != nil { if err := json.NewEncoder(w).Encode(response); err != nil {