Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.73 KB | None | 0 0
  1. func LogEndOfRequestHandler(a *app.Application) func(http.Handler) http.Handler {
  2.     return func(next http.Handler) http.Handler {
  3.         return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  4.             defer func() {
  5.                 requestId := r.Header.Get(contextutils.HeaderRequestId)
  6.                 a.Logger.Infof("HEADER REQUEST ID: %+v", requestId)
  7.                 value := r.Context().Value(contextutils.ContextRequestIDKey)
  8.                 a.Logger.Infof("CONTEXT REQUEST ID: %+v", value)
  9.                 sessionId := r.Header.Get(contextutils.HeaderSessionIdKey)
  10.                 a.Logger.Infof("HEADER REQUEST ID: %+v", sessionId)
  11.                 client := r.Context().Value(contextutils.ContextClientKey)
  12.                 a.Logger.Infof("CONTEXT CLIENT STRUCT: %+v", client)
  13.             }()
  14.             next.ServeHTTP(w, r)
  15.         })
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement