service/library/middleware/response_encryptor.go

25 lines
522 B
Go

package middleware
import (
"service/api/base"
"service/library/logger"
interceptor "service/library/taginterceptor"
"github.com/gin-gonic/gin"
)
func ResponseEncryptor() gin.HandlerFunc {
return func(ctx *gin.Context) {
if req, exists := ctx.Get("pending_data"); exists {
err := interceptor.EncryptTagInterceptorInstance().Intercept(req, "jcrypto")
if !base.CheckBadRequest(ctx, err) {
logger.Error("返回加密失败:%v", err)
return
}
ctx.Set("pending_data", req)
ctx.Next()
}
}
}