Skip to content
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

新的框架中,如何在 Controller 自定义 status_code ? #23

Open
yangyanqing opened this issue May 17, 2022 · 0 comments
Open

新的框架中,如何在 Controller 自定义 status_code ? #23

yangyanqing opened this issue May 17, 2022 · 0 comments

Comments

@yangyanqing
Copy link

controller 中没有其他的返回接口,带 error 只能返回 5xx,无法返回 401/403 之类的错误
看调用栈也只是捕获了异常,没有利用 ctx 反向传递结果,请问这种架构下如何自定义返回码呢?

func (c *cUser) SignIn(ctx context.Context, req *v1.UserSignInReq) (res *v1.UserSignInRes, err error) {
	err = service.User().SignIn(ctx, model.UserSignInInput{
		Passport: req.Passport,
		Password: req.Password,
	})
	return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant