httpx.Error response without body (#982)

* httpx.Error support response without body

* fix doc
This commit is contained in:
Vee Zhang
2021-09-01 19:33:33 +08:00
committed by GitHub
parent 423955c55f
commit 76fc1ef460
3 changed files with 36 additions and 14 deletions

View File

@@ -25,6 +25,11 @@ func Error(w http.ResponseWriter, err error) {
}
code, body := errorHandler(err)
if body == nil {
w.WriteHeader(code)
return
}
e, ok := body.(error)
if ok {
http.Error(w, e.Error(), code)