more optimizations
Build / Build (push) Successful in 32s

This commit is contained in:
wt committed 2025-07-07 22:40:06 +07:00
1 parent 952587df4f
commit efcb19aa2f
19 files changed
+276 -189

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package utils
import (
"encoding/json"
"net/http"
)
// Helper to write JSON responses
func RespondWithJSON(w http.ResponseWriter, data any, statusCode int) {
jsonData, err := json.Marshal(data)
if err != nil {
http.Error(w, "failed to marshal JSON", http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
w.Write(jsonData)
}