add: 提交
This commit is contained in:
30
lib/midware/midhandle.go
Normal file
30
lib/midware/midhandle.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package midware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ems.agt/lib/log"
|
||||
)
|
||||
|
||||
func LoggerTraceMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Do stuff here
|
||||
log.Trace("Http Trace Info:")
|
||||
log.Trace(" From Host:", r.RemoteAddr)
|
||||
log.Trace(" To Host:", r.Host)
|
||||
log.Debug(" RequestUri:", r.RequestURI)
|
||||
log.Trace(" Method:", r.Method)
|
||||
log.Trace(" Proto:", r.Proto)
|
||||
log.Trace(" ContentLength:", r.ContentLength)
|
||||
log.Trace(" User-Agent:", r.Header.Get("User-Agent"))
|
||||
log.Trace(" Content-Type:", r.Header.Get("Content-Type"))
|
||||
log.Trace(" AccessToken:", r.Header.Get("AccessToken"))
|
||||
log.Trace("Trace End=====")
|
||||
//body, _ := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||
// nop-close to ready r.Body !!!
|
||||
//r.Body = ioutil.NopCloser(bytes.NewReader(body))
|
||||
//log.Trace("Body:", string(body))
|
||||
// Call the next handler, which can be another middleware in the chain, or the final handler.
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user