访问日志实现记录和显示requestBody

This commit is contained in:
刘祥超
2021-12-07 15:03:48 +08:00
parent 56010e7203
commit b72d91d0d4
4 changed files with 75 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import (
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
"net/http"
"strings"
)
type ViewPopupAction struct {
@@ -98,5 +99,19 @@ func (this *ViewPopupAction) RunGet(params struct {
}
this.Data["region"] = regionMap
// 请求内容
this.Data["requestBody"] = string(accessLog.RequestBody)
this.Data["requestContentType"] = "text/plain"
requestContentType, ok := accessLog.Header["Content-Type"]
if ok {
if len(requestContentType.Values) > 0 {
var contentType = requestContentType.Values[0]
if strings.HasSuffix(contentType, "/json") || strings.Contains(contentType, "/json;") {
this.Data["requestContentType"] = "application/json"
}
}
}
this.Show()
}