From 416d494e506c47e73c2a4fed2f6d065613c8b91b Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 1 Feb 2022 11:22:18 +0300 Subject: [PATCH] lazy codec init Signed-off-by: Vasiliy Tolstov --- handler.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/handler.go b/handler.go index cdda21e..a555f43 100644 --- a/handler.go +++ b/handler.go @@ -97,11 +97,6 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { h.errorHandler(ctx, nil, w, r, fmt.Errorf("path must starts with /"), http.StatusBadRequest) return } - cf, err := h.newCodec(ct) - if err != nil { - h.errorHandler(ctx, nil, w, r, err, http.StatusBadRequest) - return - } matches := make(map[string]interface{}) @@ -166,6 +161,12 @@ func (h *httpServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { } } + cf, err := h.newCodec(ct) + if err != nil { + h.errorHandler(ctx, nil, w, r, err, http.StatusBadRequest) + return + } + var argv, replyv reflect.Value // Decode the argument value. -- 2.45.2