mirror of
https://github.com/owncast/owncast.git
synced 2025-11-03 04:27:18 +08:00
Disable caching of some GET apis. Closes #1530
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"github.com/owncast/owncast/core/transcoder"
|
"github.com/owncast/owncast/core/transcoder"
|
||||||
"github.com/owncast/owncast/models"
|
"github.com/owncast/owncast/models"
|
||||||
|
"github.com/owncast/owncast/router/middleware"
|
||||||
"github.com/owncast/owncast/utils"
|
"github.com/owncast/owncast/utils"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
@ -17,7 +18,7 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
||||||
usernameBlocklist := data.GetForbiddenUsernameList()
|
usernameBlocklist := data.GetForbiddenUsernameList()
|
||||||
|
|
||||||
var videoQualityVariants = make([]models.StreamOutputVariant, 0)
|
videoQualityVariants := make([]models.StreamOutputVariant, 0)
|
||||||
for _, variant := range data.GetStreamOutputVariants() {
|
for _, variant := range data.GetStreamOutputVariants() {
|
||||||
videoQualityVariants = append(videoQualityVariants, models.StreamOutputVariant{
|
videoQualityVariants = append(videoQualityVariants, models.StreamOutputVariant{
|
||||||
Name: variant.GetName(),
|
Name: variant.GetName(),
|
||||||
@ -66,6 +67,8 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
middleware.DisableCache(w)
|
||||||
|
|
||||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/owncast/owncast/core"
|
"github.com/owncast/owncast/core"
|
||||||
"github.com/owncast/owncast/core/data"
|
"github.com/owncast/owncast/core/data"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,6 +29,8 @@ func Status(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
middleware.DisableCache(w)
|
||||||
|
|
||||||
err := json.NewEncoder(w).Encode(response)
|
err := json.NewEncoder(w).Encode(response)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln(err)
|
log.Errorln(err)
|
||||||
|
|||||||
@ -37,8 +37,6 @@ func GetChatMessages(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// RegisterAnonymousChatUser will register a new user.
|
// RegisterAnonymousChatUser will register a new user.
|
||||||
func RegisterAnonymousChatUser(w http.ResponseWriter, r *http.Request) {
|
func RegisterAnonymousChatUser(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
|
|
||||||
if r.Method != POST {
|
if r.Method != POST {
|
||||||
WriteSimpleResponse(w, false, r.Method+" not supported")
|
WriteSimpleResponse(w, false, r.Method+" not supported")
|
||||||
return
|
return
|
||||||
@ -72,5 +70,8 @@ func RegisterAnonymousChatUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
DisplayName: newUser.DisplayName,
|
DisplayName: newUser.DisplayName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
middleware.DisableCache(w)
|
||||||
|
|
||||||
WriteResponse(w, response)
|
WriteResponse(w, response)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ type webConfigResponse struct {
|
|||||||
// GetWebConfig gets the status of the server.
|
// GetWebConfig gets the status of the server.
|
||||||
func GetWebConfig(w http.ResponseWriter, r *http.Request) {
|
func GetWebConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
middleware.EnableCors(w)
|
middleware.EnableCors(w)
|
||||||
|
middleware.DisableCache(w)
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
pageContent := utils.RenderPageContentMarkdown(data.GetExtraPageBodyContent())
|
pageContent := utils.RenderPageContentMarkdown(data.GetExtraPageBodyContent())
|
||||||
|
|||||||
@ -24,6 +24,8 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
middleware.DisableCache(w)
|
||||||
|
|
||||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
InternalErrorHandler(w, err)
|
InternalErrorHandler(w, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user