fix: 脱敏认证请求日志
This commit is contained in:
@@ -18,9 +18,7 @@ func GetMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
l := user.NewGetMeLogic(r.Context(), svcCtx)
|
l := user.NewGetMeLogic(r.Context(), svcCtx)
|
||||||
resp, err := l.GetMe()
|
resp, err := l.GetMe()
|
||||||
logx.Infof("req header: %v", r.Header)
|
logx.Infof("getMe requestId=%s userId=%s", r.Header.Get("x-request-id"), r.Header.Get("x-auth-user-id"))
|
||||||
logx.Infof("cookies: %v", r.Cookies())
|
|
||||||
//r.Cookie()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpx.ErrorCtx(r.Context(), w, err)
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,8 +16,15 @@ func NewHeaderExtractorMiddleware() *HeaderExtractorMiddleware {
|
|||||||
|
|
||||||
func (m *HeaderExtractorMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
func (m *HeaderExtractorMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
header := r.Header
|
logx.Infof(
|
||||||
logx.Infof("headerExtractorMiddleware header: %v", header)
|
"headerExtractorMiddleware method=%s path=%s requestId=%s hasUserId=%t hasIsAdmin=%t hasCookie=%t",
|
||||||
|
r.Method,
|
||||||
|
r.URL.Path,
|
||||||
|
r.Header.Get("x-request-id"),
|
||||||
|
r.Header.Get("x-auth-user-id") != "",
|
||||||
|
r.Header.Get("x-auth-is-admin") != "",
|
||||||
|
r.Header.Get("cookie") != "",
|
||||||
|
)
|
||||||
|
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user