Add admin UI
Some checks failed
CI / Test (pull_request) Failing after 1m33s
CI / Lint (pull_request) Failing after 13s
CI / Build (pull_request) Has been skipped
CI / Security Scan (pull_request) Failing after 4m47s
CI / Build and Push Docker Image (pull_request) Has been skipped

This commit is contained in:
2026-03-05 23:08:34 +00:00
parent 667217e66b
commit 7025ec746c
31 changed files with 5905 additions and 3 deletions

View File

@@ -0,0 +1,45 @@
package admin
import (
"encoding/json"
"net/http"
)
// APIResponse is the standard JSON response wrapper.
type APIResponse struct {
Success bool `json:"success"`
Data interface{} `json:"data,omitempty"`
Error *APIError `json:"error,omitempty"`
}
// APIError represents an error response.
type APIError struct {
Code string `json:"code"`
Message string `json:"message"`
}
// writeJSON writes a JSON response.
func writeJSON(w http.ResponseWriter, statusCode int, data interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(statusCode)
json.NewEncoder(w).Encode(data)
}
// writeSuccess writes a successful JSON response.
func writeSuccess(w http.ResponseWriter, data interface{}) {
writeJSON(w, http.StatusOK, APIResponse{
Success: true,
Data: data,
})
}
// writeError writes an error JSON response.
func writeError(w http.ResponseWriter, statusCode int, code, message string) {
writeJSON(w, statusCode, APIResponse{
Success: false,
Error: &APIError{
Code: code,
Message: message,
},
})
}