Fix embedded static files on production builds

This commit is contained in:
Eli Ribble 2026-03-21 05:38:42 +00:00
parent 9cbce4ff14
commit a2c3f52ab4
No known key found for this signature in database
12 changed files with 209 additions and 3083 deletions

View file

@ -6,33 +6,6 @@ import (
"github.com/rs/zerolog/log"
)
// Custom ResponseWriter to track Content-Type
type customResponseWriter struct {
http.ResponseWriter
contentType string
wroteHeader bool
}
func (crw *customResponseWriter) WriteHeader(code int) {
crw.wroteHeader = true
crw.ResponseWriter.WriteHeader(code)
}
func (crw *customResponseWriter) Header() http.Header {
return crw.ResponseWriter.Header()
}
func (crw *customResponseWriter) Write(b []byte) (int, error) {
if !crw.wroteHeader {
if crw.contentType == "" {
crw.contentType = http.DetectContentType(b)
crw.ResponseWriter.Header().Set("Content-Type", crw.contentType)
}
crw.WriteHeader(http.StatusOK)
}
return crw.ResponseWriter.Write(b)
}
// Respond with an error that is visible to the user
func RespondError(w http.ResponseWriter, m string, e error, s int) {
log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error")