update: add resp 418

This commit is contained in:
root 2024-09-19 01:43:05 -07:00
parent 940e86bd8d
commit 5367d1e754
2 changed files with 15 additions and 1 deletions

View File

@ -2,9 +2,10 @@ package resp
import ( import (
"fmt" "fmt"
"github.com/loveuer/nf"
"strconv" "strconv"
"strings" "strings"
"github.com/loveuer/nf"
) )
func handleEmptyMsg(status uint32, msg string) string { func handleEmptyMsg(status uint32, msg string) string {
@ -102,6 +103,18 @@ func Resp403(c *nf.Ctx, data any, msgs ...string) error {
return Resp(c, 403, msg, err, data) return Resp(c, 403, msg, err, data)
} }
func Resp418(c *nf.Ctx, data any, msgs ...string) error {
msg := MSG418
err := ""
if len(msgs) > 0 && msgs[0] != "" {
msg = fmt.Sprintf("%s: %s", msg, strings.Join(msgs, "; "))
err = ""
}
return Resp(c, 418, msg, err, data)
}
func Resp429(c *nf.Ctx, data any, msgs ...string) error { func Resp429(c *nf.Ctx, data any, msgs ...string) error {
msg := MSG429 msg := MSG429
err := "" err := ""

View File

@ -7,6 +7,7 @@ const (
MSG401 = "登录已过期, 请重新登录" MSG401 = "登录已过期, 请重新登录"
MSG403 = "请求权限不足" MSG403 = "请求权限不足"
MSG404 = "请求资源未找到" MSG404 = "请求资源未找到"
MSG418 = "请求条件不满足, 请稍后再试"
MSG429 = "请求过于频繁, 请稍后再试" MSG429 = "请求过于频繁, 请稍后再试"
MSG500 = "服务器开小差了, 请稍后再试" MSG500 = "服务器开小差了, 请稍后再试"
MSG501 = "功能开发中, 尽情期待" MSG501 = "功能开发中, 尽情期待"