#go-chi passing data via context from middleware panicking

6 messages · Page 1 of 1 (latest)

rustic fossil
#

in uid := r.Context().Value("user-id") "user-id" is of type string, not contextKey

#

since it's a different type it's not the same key

#

lift this const user_id_key contextKey = "user-id" to the global scope and use it

#

that's not an alias, and no, you don't need to change it back

#

to get the value you need to use the same key