add rest api for api_bb vue a lot of files

This commit is contained in:
2025-10-09 05:59:40 +05:00
parent 654c682b05
commit 700e404a06
17 changed files with 512 additions and 211 deletions
+16
View File
@@ -0,0 +1,16 @@
package utils
import (
"encoding/json"
"net/http"
)
func RespondWithJSON(w http.ResponseWriter, statusCode int, data interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
json.NewEncoder(w).Encode(data)
}
func RespondWithError(w http.ResponseWriter, statusCode int, message string) {
RespondWithJSON(w, statusCode, map[string]string{"error": message})
}