this repo has no description
1package utility
2
3import (
4 "encoding/json"
5 "net/http"
6
7 "github.com/eagleusb/proxycon/internal/types"
8)
9
10// WriteJSONError writes a JSON-formatted error response for consistency.
11func WriteJSONError(w http.ResponseWriter, message string, code int) {
12 w.Header().Set("Content-Type", "application/json")
13 w.WriteHeader(code)
14 json.NewEncoder(w).Encode(types.ErrorResponse{Code: code, Message: message})
15}