24 lines
341 B
Go
24 lines
341 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func WriteError(
|
|
w http.ResponseWriter,
|
|
code int,
|
|
errCode string,
|
|
msg string,
|
|
) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(code)
|
|
|
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
|
"error": map[string]any{
|
|
"code": errCode,
|
|
"message": msg,
|
|
},
|
|
})
|
|
}
|