-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add custom unset err when parse request #3460
base: master
Are you sure you want to change the base?
feat: add custom unset err when parse request #3460
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
i use with i18n ......
ctx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf, rest.WithCors(), errorx.RouteMethodNotAllow(), func(server *rest.Server) {
fmt.Println("MustNewServer")
})
server.Use(i18nx.NewMiddleware(c.LocalizationFiles...).Handle)
server.Use(validator.NewMiddleware().Handle)
httpx.SetCustomUnsetError(func(ctx context.Context, fieldName string) error {
name := goi18nx.FormatText(ctx, fmt.Sprintf("Parameters.%s", fieldName), fieldName)
msg := goi18nx.FormatTextWithData(ctx, "Parameters.UnsetErr", fmt.Sprintf("%s is unset", fieldName), map[string]interface{}{"name": name})
return errorx.NewErrMsg(msg)
})
defer server.Stop()
...... |
269bcfb
to
70d652a
Compare
…thub.com/SpectatorNan/go-zero into support-request-custom-field-not-set-err
Support parameter not set custom exception
replace
to custom error
such as internationalization support