package midware import ( "net/http" "ems.agt/lib/log" "ems.agt/lib/services" ) 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. if r.Method == "OPTIONS" { services.ResponseStatusOK201Accepted(w) return } next.ServeHTTP(w, r) }) }