canceler.go 475 B

123456789101112131415161718192021222324
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build go1.5
  5. package cancellable
  6. import (
  7. "net/http"
  8. "github.com/docker/engine-api/client/transport"
  9. )
  10. func canceler(client transport.Sender, req *http.Request) func() {
  11. // TODO(djd): Respect any existing value of req.Cancel.
  12. ch := make(chan struct{})
  13. req.Cancel = ch
  14. return func() {
  15. close(ch)
  16. }
  17. }