How to pass a data for views from Middleware

Comment From: mohsalsaleem

You could possibly use gin.Context. Get the context in middleware, set the key value and you will be able to get it in the handler.

Comment From: bbdshow

c.Set('k', 'b') or c.Set('k', &someStruct{}) c.Get(k).(string) or c.Get(k).(*someStruct)

Comment From: batara666

nope, You still need to bring the data to data variable

c.HTML(200, view, data)