github.com/xmidt-org/webpa-common@v1.11.9/device/drain/cancel.go (about) 1 package drain 2 3 import "net/http" 4 5 // Cancel is an HTTP handler that allows cancellation of drain jobs 6 type Cancel struct { 7 Drainer Interface 8 } 9 10 func (c *Cancel) ServeHTTP(response http.ResponseWriter, request *http.Request) { 11 done, err := c.Drainer.Cancel() 12 if err != nil { 13 response.WriteHeader(http.StatusConflict) 14 return 15 } 16 17 select { 18 case <-done: 19 case <-request.Context().Done(): 20 } 21 }