@@ -44,29 +44,32 @@ func (b Request) Handler(entry *logrus.Entry) (*entries, []tag) {
4444 ginCtx := ctx .(* gin.Context )
4545 res = ginCtx .Writer
4646 telescopeResp := res .(* TelescopeResponseWriter )
47+ responseBody := telescopeResp .Body .Bytes ()
48+ if len (telescopeResp .DecodeBody ) != 0 {
49+ responseBody = telescopeResp .DecodeBody
50+ }
4751
4852 responseJSON := map [string ]interface {}{}
49- err := json .Unmarshal (telescopeResp . Body . Bytes () , & responseJSON )
53+ err := json .Unmarshal (responseBody , & responseJSON )
5054 if err != nil || len (responseJSON ) == 0 {
5155 b .Response = telescopeResp .Body .String ()
5256 } else {
5357 b .Response = responseJSON
5458 }
5559
56- // 原始请求数据
57- if ginCtx .Request .PostForm == nil {
58- raw , ok := ginCtx .Get ("raw" )
59- if ok {
60- switch raw .(type ) {
61- case string :
62- data := raw .(string )
63- _ = json .Unmarshal ([]byte (data ), & b .Payload )
64- case []byte :
65- data := raw .([]byte )
66- _ = json .Unmarshal (data , & b .Payload )
67- }
60+ // 原始请求数据, 如果加密场景可以直接设置
61+ raw , ok := ginCtx .Get ("raw" )
62+ if ok {
63+ switch raw .(type ) {
64+ case string :
65+ data := raw .(string )
66+ _ = json .Unmarshal ([]byte (data ), & b .Payload )
67+ case []byte :
68+ data := raw .([]byte )
69+ _ = json .Unmarshal (data , & b .Payload )
6870 }
69- } else {
71+ }
72+ if ginCtx .Request .PostForm != nil {
7073 for k , v := range ginCtx .Request .PostForm {
7174 b .Payload [k ] = v [0 ]
7275 }
0 commit comments