You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs say that examples using next should be present in this repo (https://pkg.go.dev/github.com/gin-gonic/gin#Context.Next). I'm a bit confused on the lifecycle of middleware. For example, say we have the following middleware:
I had some trouble finding the example documentation in Github like the comment stated, but the documentation here on the gin-gonic website seemed to do an ok job. As I understand it, the lifecycle for middleware focusing on just the usage of context.Next() is:
Request comes in
Your middleware is hit
context.Next() tells gin to short-circuit your middleware logic and go to the next middleware in the chain
the response is sent out
The logic aftercontext.Next() is now run. Which is why in the example, the only thing that can be done is to log out how long it took to create the response. And you can't actually send out that value in the response itself.
The docs say that examples using
next
should be present in this repo (https://pkg.go.dev/github.com/gin-gonic/gin#Context.Next). I'm a bit confused on the lifecycle of middleware. For example, say we have the following middleware:My goal here is to include the time it took to process the request as a response header. Is the above correct way of doing this?
The text was updated successfully, but these errors were encountered: