proxy.go 435 B

1234567891011121314151617181920
  1. package proxy
  2. import (
  3. "context"
  4. "github.com/docker/api/client"
  5. )
  6. type clientKey struct{}
  7. // WithClient adds the client to the context
  8. func WithClient(ctx context.Context, c *client.Client) (context.Context, error) {
  9. return context.WithValue(ctx, clientKey{}, c), nil
  10. }
  11. // Client returns the client from the context
  12. func Client(ctx context.Context) *client.Client {
  13. c, _ := ctx.Value(clientKey{}).(*client.Client)
  14. return c
  15. }