From cec99493f2aa6e9f674ede81a4c6d1e038864f1f Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 20 Apr 2023 10:19:05 +0200 Subject: [PATCH] Add workaround for chiRouter racecondition in chi.RegisterMethod() Co-authored-by: Ralf Haferkamp Signed-off-by: Christian Richter --- services/proxy/pkg/command/server.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index e61dd9ff60..4f78a318f7 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -191,11 +191,6 @@ type StaticRouteHandler struct { func (h *StaticRouteHandler) handler() http.Handler { m := chi.NewMux() - var methods = []string{"PROPFIND", "DELETE", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK", "REPORT"} - for _, k := range methods { - chi.RegisterMethod(k) - } - m.Route(h.prefix, func(r chi.Router) { // Wrapper for backchannel logout r.Post("/backchannel_logout", h.backchannelLogout) @@ -204,6 +199,16 @@ func (h *StaticRouteHandler) handler() http.Handler { r.HandleFunc("/*", h.proxy.ServeHTTP) }) + // This is commented out due to a race issue in chi + //var methods = []string{"PROPFIND", "DELETE", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK", "REPORT"} + //for _, k := range methods { + // chi.RegisterMethod(k) + //} + + // To avoid using the chi.RegisterMethod() this is basically a catchAll for all HTTP Methods that are not + // covered in chi by default + m.MethodNotAllowed(h.proxy.ServeHTTP) + return m }