eg: in my auth mddleware -
c.Set("user", user)
c.Next()
and then in my controller -
user := c.Keys["user"].(models.User)
is there any problem with this approach other than maybe in the future the api for Context.Keys might reserve "user" or something?
Comment From: itzjustalan
or any other approach to get the same express like behavior is appreciated. since struct is way bigger than a map size wise? idk what im talking about 😅😅
Comment From: mohsalsaleem
As the comment for the method Set suggests, it is okay for you to use Set method to specify key value pair that you use within that request/context.
Also, I'm not sure about what you mean by struct being way bigger than map size wise. They are not. The size of struct is based on what it holds.
Comment From: ericbrown30
If the scope is for given single request only, then you can go for this approach otherwise you should pass it in some other way.