mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver/etcdhttp: response with 504
This commit is contained in:
parent
735647e6a3
commit
7638acdf37
@ -56,7 +56,9 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
panic("TODO")
|
||||
}
|
||||
|
||||
encodeResponse(ctx, w, resp)
|
||||
if err := encodeResponse(ctx, w, resp); err != nil {
|
||||
http.Error(w, "Timeout while waiting for response", 504)
|
||||
}
|
||||
}
|
||||
|
||||
func parseRequest(r *http.Request) (etcdserver.Request, error) {
|
||||
@ -89,7 +91,10 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, resp etcdserver.
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
return json.NewEncoder(w).Encode(ev)
|
||||
if err := json.NewEncoder(w).Encode(ev); err != nil {
|
||||
panic(err) // should never be reached
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func canBlock(r etcdserver.Request) bool {
|
||||
|
Loading…
x
Reference in New Issue
Block a user