mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
22 lines
433 B
Go
22 lines
433 B
Go
package middleware
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/go-rat/chix"
|
|
)
|
|
|
|
func Abort(w http.ResponseWriter, code int, format string, args ...any) {
|
|
render := chix.NewRender(w)
|
|
defer render.Release()
|
|
render.Header(chix.HeaderContentType, chix.MIMEApplicationJSONCharsetUTF8) // must before Status()
|
|
render.Status(code)
|
|
if len(args) > 0 {
|
|
format = fmt.Sprintf(format, args...)
|
|
}
|
|
render.JSON(chix.M{
|
|
"msg": format,
|
|
})
|
|
}
|