Can golang gin get session anywhere in the current request?

for example, when java is in the same request, you can get the information directly in the context of spring without sending the request of the current request. Can
be done in gin? The main problem now is that all the places where you want to get the session from the request have to pass the context back and forth, unlike in java, you can get it anywhere using the tool class UserUtils.getUser () without passing parameters.
gin, if there are many UserUtils.getUser (context), parameters, almost every method has to take this parameter

.
Aug.22,2021

use middleware
e: = gin.New ()
e.Use (XXX)
in this way, you can put user-related or other data into ctx
you can get data through ctx at any request, encapsulate it, and then


you can see the example of gin session package .
use sessions, can be followed directly by get session information in a gin application.

Menu