Add workaround for chiRouter racecondition in chi.RegisterMethod()

Co-authored-by: Ralf Haferkamp <rhaferkamp@owncloud.com>
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2023-04-20 10:19:05 +02:00
parent 30bcf32062
commit cec99493f2
+10 -5
View File
@@ -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
}