This commit is contained in:
cangui 2025-06-22 19:16:09 +02:00
parent 67ba36abd4
commit 4f6051d1e6

View File

@ -4,6 +4,7 @@ import (
"app/shelfly/internal/debridlink"
"app/shelfly/internal/download"
"app/shelfly/internal/models"
"bytes"
"context"
"encoding/json"
"fmt"
@ -1146,10 +1147,16 @@ func HLSStream(db *gorm.DB) http.HandlerFunc {
func renderPartial(w http.ResponseWriter, templ string, data map[string]interface{}) {
// Exécute directement le define `<templ>.pages.tmpl`
if err := templates.ExecuteTemplate(w, templ+".pages.tmpl", data); err != nil {
var buf bytes.Buffer
// Exécute la template dans le buffer
if err := templates.ExecuteTemplate(&buf, templ+".pages.tmpl", data); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// On peut définir un content-type explicite si besoin
w.Header().Set("Content-Type", "text/html; charset=utf-8")
// Écriture unique du code 200 implicite et du corps
w.Write(buf.Bytes())
}
func renderTemplate(w http.ResponseWriter, templ string, data map[string]interface{}) {