Files
ForgeBucket/internal/api/handlers/helpers.go
T
2026-05-06 23:39:04 +02:00

18 lines
397 B
Go

package handlers
import (
"encoding/json"
"net/http"
)
func jsonError(w http.ResponseWriter, message string, status int) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(status)
json.NewEncoder(w).Encode(map[string]string{"error": message})
}
func jsonOK(w http.ResponseWriter, v any) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(v)
}