Serve artist placeholder directly, instead of using LastFM's CDN

This commit is contained in:
Deluan
2022-12-30 20:14:03 -05:00
parent b8c171d3d4
commit 6260927074
6 changed files with 79 additions and 12 deletions
+11 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"path"
"strings"
"time"
"github.com/go-chi/chi/v5"
@@ -94,7 +95,8 @@ func (s *Server) initRoutes() {
r.Use(middleware.Recoverer)
r.Use(compressMiddleware())
r.Use(middleware.Heartbeat("/ping"))
r.Use(clientUniqueIdAdder)
r.Use(serverAddressMiddleware)
r.Use(clientUniqueIDMiddleware)
r.Use(loggerInjector)
r.Use(requestLogger)
r.Use(robotsTXT(ui.BuildAssets()))
@@ -135,3 +137,11 @@ func (s *Server) frontendAssetsHandler() http.Handler {
r.Handle("/*", http.StripPrefix(s.appRoot, http.FileServer(http.FS(ui.BuildAssets()))))
return r
}
func AbsoluteURL(r *http.Request, url string) string {
if strings.HasPrefix(url, "/") {
appRoot := path.Join(r.Host, conf.Server.BaseURL, url)
url = r.URL.Scheme + "://" + appRoot
}
return url
}