feat(router,errors): BadRequest error

This commit is contained in:
Guz
2024-10-24 19:36:35 -03:00
parent f27784a0b2
commit 6372b20a0b

View File

@@ -2,8 +2,21 @@ package rerrors
import (
"net/http"
"strconv"
)
func BadRequest(reason ...string) RouteError {
info := map[string]any{}
if len(reason) == 1 {
info["reason"] = reason[0]
} else if len(reason) > 1 {
for i, r := range reason {
info["reason_"+strconv.Itoa(i)] = r
}
}
return NewRouteError(http.StatusBadRequest, "Bad Request", info)
}
func NotFound() RouteError {