-
-
Notifications
You must be signed in to change notification settings - Fork 1k
How to access keys in Context?
frederikhors edited this page Jan 9, 2019
·
1 revision
@pkieltyka, the author https://github.com/go-chi/chi/issues/375#issuecomment-452393057 said:
The context key's are actually a unique object with an underlying string value. This is by design to prevent collisions with other packages, specifically this value: https://github.com/go-chi/chi/blob/master/context.go#L12.
You'll want to update use
ctx.Value(chi.RouteCtxKey).(*chi.Context)
but even easier is to dorouteCtx := chi.RouteContext(ctx)
.