goth icon indicating copy to clipboard operation
goth copied to clipboard

Feat: Allow adding custom values to session

Open g3ano opened this issue 7 months ago • 0 comments

I ran into a situation where I needed to retain a small state between the oauth initialization and callback step

the package currently exposes a StoreInSession function to write key/value to the session. The issue is that it commits the session to the request after setting that value, so any other calls to the function will overrides the previous values

to work around this, I ended up creating a separate short-lived session (alongside the gothic session) that lives only during the oauth flow, it works but it adds unnecessary complexity for just storing a couple of values temporarily

I think its fine to have separate session to manage long-lived states, but for use cases like mine, it would be more efficient to have a way to write multiple values at once

something like:

// current
StoreInSession(key string, value string, req *http.Request, res http.ResponseWriter)

// suggested
StoreInSessionValues(values map[string]string, req *http.Request, res http.ResponseWriter)

g3ano avatar Jun 03 '25 00:06 g3ano