service/library/middleware/response_encryptor.go

25 lines
522 B
Go
Raw Permalink Normal View History

2023-12-21 22:17:40 +08:00
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()
}
}
}