feat: 优化after hook的逻辑

This commit is contained in:
2026-01-04 22:54:04 +08:00
parent e0ba683411
commit 19056208c8
2 changed files with 4 additions and 3 deletions

View File

@@ -137,6 +137,7 @@ func (s *server) formatError(ctx *gin.Context, err any) exception.IException {
// RequestHandler 获取请求处理方法
func (s *server) RequestHandler(uriCfg define.UriConfig) gin.HandlerFunc {
return func(ctx *gin.Context) {
defer s.hook(ctx, uriCfg)
var (
e exception.IException
handleResult any
@@ -151,7 +152,6 @@ func (s *server) RequestHandler(uriCfg define.UriConfig) gin.HandlerFunc {
return
}
defer s.hook(ctx, uriCfg) // 执行 Logic 之后的相关逻辑
if handleResult, e = s.callFunc(ctx, uriCfg, inputValue); nil == e {
response.SuccessWithExtension(ctx, handleResult, &define.ResponseOption{ContentType: consts.MimeTypeJson})
return