func CloseNotify(next http.Handler) http.Handler {
	fn := func(w http.ResponseWriter, r *http.Request) {
		cn, ok := w.(http.CloseNotifier)
		if !ok {
			panic("chi/middleware: CloseNotify expects http.ResponseWriter to implement http.CloseNotifier interface")
		}
		closeNotifyCh := cn.CloseNotify()
		go func() {
			select {
			case <-closeNotifyCh:
				w.WriteHeader(StatusClientClosedRequest)
				return
			}
		}()
		next.ServeHTTP(w, r)
	}
	return http.HandlerFunc(fn)
}
CloseNotify is a middleware that cancels ctx when the underlying
connection has gone away. It can be used to cancel long operations
on the server when the client disconnects before the response is ready.
package middleware
import "net/http"
const StatusClientClosedRequest = 499