transfer_rs/cmd/api/internal/middleware/decryptMiddleware.go

43 lines
961 B
Go
Raw Normal View History

2024-06-19 18:05:50 +08:00
package middleware
import (
"rs/cmd/api/internal/types"
)
type DecryptMiddleware struct {
svcCtx *types.BaseServiceContext
}
func NewDecryptMiddleware(svcCtx *types.BaseServiceContext) *DecryptMiddleware {
return &DecryptMiddleware{
svcCtx: svcCtx,
}
}
type BaseReq struct {
VendorNo string `json:"vendorNo"`
Data string `json:"data"`
Sign string `json:"sign"`
DecryptData string `json:"decrypt_data"`
}
//func (m *DecryptMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
// return func(w http.ResponseWriter, r *http.Request) {
// var (
// baseReq BaseReq
// deCrypt []byte
// )
//
// body, err := io.ReadAll(r.Body)
//
// defer r.Body.Close()
// _ = json.Unmarshal(body, &baseReq)
//
// baseReq.DecryptData = string(deCrypt)
// baseReqJson, _ := json.Marshal(baseReq)
// r.Body = io.NopCloser(bytes.NewReader(baseReqJson))
// // 创建一个新的Reader并设置为请求的Body
// next(w, r)
// }
//}