Skip to content

Commit

Permalink
implement workaround for chi.RegisterMethod (#2785)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas authored Apr 27, 2022
1 parent 8cad2e5 commit 618964e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/chi-method-workaround.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Change: Implement workaround for chi.RegisterMethod

Implemented a workaround for `chi.RegisterMethod` because of a concurrent map read write issue.
This needs to be fixed upstream in go-chi.

https://github.com/cs3org/reva/pull/2785
22 changes: 14 additions & 8 deletions pkg/micro/ocdav/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,28 @@ func Service(opts ...Option) (micro.Service, error) {
return nil, err
}

// Comment back in after resolving the issue in go-chi.
// See comment in line 87.
// register additional webdav verbs
chi.RegisterMethod(ocdav.MethodPropfind)
chi.RegisterMethod(ocdav.MethodProppatch)
chi.RegisterMethod(ocdav.MethodLock)
chi.RegisterMethod(ocdav.MethodUnlock)
chi.RegisterMethod(ocdav.MethodCopy)
chi.RegisterMethod(ocdav.MethodMove)
chi.RegisterMethod(ocdav.MethodMkcol)
chi.RegisterMethod(ocdav.MethodReport)
// chi.RegisterMethod(ocdav.MethodPropfind)
// chi.RegisterMethod(ocdav.MethodProppatch)
// chi.RegisterMethod(ocdav.MethodLock)
// chi.RegisterMethod(ocdav.MethodUnlock)
// chi.RegisterMethod(ocdav.MethodCopy)
// chi.RegisterMethod(ocdav.MethodMove)
// chi.RegisterMethod(ocdav.MethodMkcol)
// chi.RegisterMethod(ocdav.MethodReport)
r := chi.NewRouter()

if err := useMiddlewares(r, &sopts, revaService); err != nil {
return nil, err
}

r.Handle("/*", revaService.Handler())
// This is a workaround for the go-chi concurrent map read write issue.
// After the issue has been solved upstream in go-chi we should switch
// back to using `chi.RegisterMethod`.
r.MethodNotAllowed(http.HandlerFunc(revaService.Handler().ServeHTTP))

hd := srv.NewHandler(r)
if err := srv.Handle(hd); err != nil {
Expand Down

0 comments on commit 618964e

Please sign in to comment.