43 lines
961 B
Go
43 lines
961 B
Go
|
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)
|
||
|
// }
|
||
|
//}
|