|
@@ -3,6 +3,7 @@ package controllers
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/sirupsen/logrus"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
|
|
@@ -128,7 +129,30 @@ func (c *BaseAuthController) JSON(data interface{}, hasIndent bool, coding bool)
|
|
|
if requestBody == "" {
|
|
|
requestBody = c.Ctx.Input.URI()
|
|
|
}
|
|
|
- utils.ApiLog.Info("请求地址:", c.Ctx.Input.URI(), "Authorization:", c.Ctx.Input.Header("Authorization"), "RequestBody:", requestBody, "ResponseBody", string(content), "IP:", ip)
|
|
|
+ authorization := c.Ctx.Input.Header("authorization")
|
|
|
+ if authorization == "" {
|
|
|
+ authorization = c.Ctx.Input.Header("Authorization")
|
|
|
+ }
|
|
|
+ var reqData interface{}
|
|
|
+ err = json.Unmarshal([]byte(requestBody), &reqData)
|
|
|
+ if err != nil {
|
|
|
+ utils.ApiLog.WithFields(logrus.Fields{
|
|
|
+ "uri": c.Ctx.Input.URI(),
|
|
|
+ "authorization": authorization,
|
|
|
+ "requestBody": requestBody,
|
|
|
+ "responseBody": data,
|
|
|
+ "ip": ip,
|
|
|
+ }).Info("请求详情")
|
|
|
+ } else {
|
|
|
+ utils.ApiLog.WithFields(logrus.Fields{
|
|
|
+ "uri": c.Ctx.Input.URI(),
|
|
|
+ "authorization": authorization,
|
|
|
+ "requestBody": reqData,
|
|
|
+ "responseBody": data,
|
|
|
+ "ip": ip,
|
|
|
+ }).Info("请求详情")
|
|
|
+ }
|
|
|
+
|
|
|
if coding {
|
|
|
content = []byte(utils.StringsToJSON(string(content)))
|
|
|
}
|