MCPcopy
hub / github.com/apache/answer / BindAndCheck

Function BindAndCheck

internal/base/handler/handler.go:64–78  ·  view source on GitHub ↗

BindAndCheck bind request and check

(ctx *gin.Context, data any)

Source from the content-addressed store, hash-verified

62
63// BindAndCheck bind request and check
64func BindAndCheck(ctx *gin.Context, data any) bool {
65 lang := GetLangByCtx(ctx)
66 if err := ctx.ShouldBind(data); err != nil {
67 log.Errorf("http_handle BindAndCheck fail, %s", err.Error())
68 HandleResponse(ctx, myErrors.New(http.StatusBadRequest, reason.RequestFormatError), nil)
69 return true
70 }
71
72 errField, err := validator.GetValidatorByLang(lang).Check(data)
73 if err != nil {
74 HandleResponse(ctx, err, errField)
75 return true
76 }
77 return false
78}
79
80// BindAndCheckReturnErr bind request and check
81func BindAndCheckReturnErr(ctx *gin.Context, data any) (errFields []*validator.FormErrorField) {

Callers 15

GetPluginListMethod · 0.92
UpdatePluginStatusMethod · 0.92
GetPluginConfigMethod · 0.92
UpdatePluginConfigMethod · 0.92
AddAPIKeyMethod · 0.92
UpdateAPIKeyMethod · 0.92
DeleteAPIKeyMethod · 0.92
UpdateUserStatusMethod · 0.92
UpdateUserRoleMethod · 0.92
AddUserMethod · 0.92
AddUsersMethod · 0.92
UpdateUserPasswordMethod · 0.92

Calls 4

GetValidatorByLangFunction · 0.92
GetLangByCtxFunction · 0.85
HandleResponseFunction · 0.85
CheckMethod · 0.65

Tested by

no test coverage detected