Error 响应错误
(w http.ResponseWriter, code int, format string, args ...any)
| 35 | |
| 36 | // Error 响应错误 |
| 37 | func Error(w http.ResponseWriter, code int, format string, args ...any) { |
| 38 | render := chix.NewRender(w) |
| 39 | defer render.Release() |
| 40 | render.Header(chix.HeaderContentType, chix.MIMEApplicationJSONCharsetUTF8) // must before Status() |
| 41 | render.Status(code) |
| 42 | if len(args) > 0 { |
| 43 | format = fmt.Sprintf(format, args...) |
| 44 | } |
| 45 | render.JSON(&ErrorResponse{ |
| 46 | Msg: format, |
| 47 | }) |
| 48 | } |
| 49 | |
| 50 | // ErrorSystem 响应系统错误 |
| 51 | func ErrorSystem(w http.ResponseWriter) { |
no test coverage detected