feature : responses whit context (#2637)

This commit is contained in:
heyehang
2022-12-03 18:48:02 +08:00
committed by GitHub
parent 9941055eaa
commit a644ec7edd
5 changed files with 192 additions and 9 deletions

View File

@@ -99,7 +99,7 @@ func (h *timeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
defer tw.mu.Unlock()
// there isn't any user-defined middleware before TimoutHandler,
// so we can guarantee that cancelation in biz related code won't come here.
httpx.Error(w, ctx.Err(), func(w http.ResponseWriter, err error) {
httpx.ErrorCtx(r.Context(), w, ctx.Err(), func(w http.ResponseWriter, err error) {
if errors.Is(err, context.Canceled) {
w.WriteHeader(statusClientClosedRequest)
} else {