+func NewContext(ctx context.Context, c *Credentials) context.Context {
+ return context.WithValue(ctx, contextKeyCredentials{}, c)
+}
+
+func FromContext(ctx context.Context) (*Credentials, bool) {
+ c, ok := ctx.Value(contextKeyCredentials{}).(*Credentials)
+ return c, ok
+}
+
+func CredentialsFromRequest(r *http.Request) *Credentials {
+ if c, ok := FromContext(r.Context()); ok {
+ // preloaded by middleware
+ return c
+ }