You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
474 B
24 lines
474 B
package respond
|
|
|
|
import "net/http"
|
|
|
|
// Error responds with a standardized error object.
|
|
func Error(w http.ResponseWriter, code int, kind string, message string) {
|
|
type errorContent struct {
|
|
Code int `json:"code"`
|
|
Kind string `json:"kind"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type errorBody struct {
|
|
Error errorContent `json:"error"`
|
|
}
|
|
|
|
JSON(w, code, &errorBody{
|
|
Error: errorContent{
|
|
Code: code,
|
|
Kind: kind,
|
|
Message: message,
|
|
},
|
|
})
|
|
}
|