From 1fd1332c92ea25e1b61ba8b1381666f339a0ce89 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Tue, 23 Feb 2021 14:38:37 +0800 Subject: [PATCH] fix middleware errors (#717) --- transport/http/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transport/http/server.go b/transport/http/server.go index 4e42f9fb7..4cfd470da 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -144,7 +144,9 @@ func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { if s.middleware != nil { h = s.middleware(h) } - h(ctx, req.WithContext(ctx)) + if _, err := h(ctx, req.WithContext(ctx)); err != nil { + s.errorEncoder(res, req, err) + } } // Endpoint return a real address to registry endpoint.