Use bundled images instead of old webroot files
This commit is contained in:
@@ -2,12 +2,8 @@ package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/amalfra/etag"
|
||||
"github.com/owncast/owncast/config"
|
||||
"github.com/owncast/owncast/utils"
|
||||
)
|
||||
|
||||
@@ -22,25 +18,6 @@ func setCacheSeconds(seconds int, w http.ResponseWriter) {
|
||||
w.Header().Set("Cache-Control", "public, max-age="+secondsStr)
|
||||
}
|
||||
|
||||
// ProcessEtags gets and sets ETags for caching purposes.
|
||||
func ProcessEtags(w http.ResponseWriter, r *http.Request) int {
|
||||
info, err := os.Stat(filepath.Join(config.WebRoot, r.URL.Path))
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
localContentEtag := etag.Generate(info.ModTime().String(), true)
|
||||
if remoteEtagHeader := r.Header.Get("If-None-Match"); remoteEtagHeader != "" {
|
||||
if remoteEtagHeader == localContentEtag {
|
||||
return http.StatusNotModified
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Etag", localContentEtag)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
// SetCachingHeaders will set the cache control header of a response.
|
||||
func SetCachingHeaders(w http.ResponseWriter, r *http.Request) {
|
||||
setCacheSeconds(utils.GetCacheDurationSecondsForPath(r.URL.Path), w)
|
||||
|
||||
@@ -25,15 +25,26 @@ import (
|
||||
|
||||
// Start starts the router for the http, ws, and rtmp.
|
||||
func Start() error {
|
||||
// static files
|
||||
// The admin web app.
|
||||
http.HandleFunc("/admin", middleware.RequireAdminAuth(controllers.IndexHandler))
|
||||
|
||||
// The primary web app.
|
||||
http.HandleFunc("/", controllers.IndexHandler)
|
||||
|
||||
// Return a single emoji image.
|
||||
http.HandleFunc("/img/emoji/", middleware.RequireAdminAuth(controllers.GetCustomEmojiImage))
|
||||
|
||||
// return the logo
|
||||
http.HandleFunc("/logo", controllers.GetLogo)
|
||||
|
||||
// return a logo that's compatible with external social networks
|
||||
http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
|
||||
|
||||
// status of the system
|
||||
http.HandleFunc("/api/status", controllers.GetStatus)
|
||||
|
||||
// custom emoji supported in the chat
|
||||
http.HandleFunc("/api/emoji", controllers.GetCustomEmoji)
|
||||
http.HandleFunc("/api/emoji", controllers.GetCustomEmojiList)
|
||||
|
||||
// chat rest api
|
||||
http.HandleFunc("/api/chat", middleware.RequireUserAccessToken(controllers.GetChatMessages))
|
||||
@@ -59,12 +70,6 @@ func Start() error {
|
||||
// list of all social platforms
|
||||
http.HandleFunc("/api/socialplatforms", controllers.GetAllSocialPlatforms)
|
||||
|
||||
// return the logo
|
||||
http.HandleFunc("/logo", controllers.GetLogo)
|
||||
|
||||
// return a logo that's compatible with external social networks
|
||||
http.HandleFunc("/logo/external", controllers.GetCompatibleLogo)
|
||||
|
||||
// return the list of video variants available
|
||||
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user