Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ocis-pkg/RegisterChiMethodOnce #6924

Open
butonic opened this issue Jul 31, 2023 · 0 comments
Open

Introduce ocis-pkg/RegisterChiMethodOnce #6924

butonic opened this issue Jul 31, 2023 · 0 comments
Labels

Comments

@butonic
Copy link
Member

butonic commented Jul 31, 2023

We should use an ocis-pkg/chi RegisterMethodOnce(method string) function that executes the chi call once per method. That would be a cleaner solution than the MethodNotAllowed workaround: we can then propery register routes ... or we submit an upstream Fix, duh ...

Related:

Our current workaround might have sideeffects in the future: go-chi/chi#776

Hm from the original workaround in #3662:

chi.RegisterMethod writes to a global map. Other parts of chi read that map and since we start multiple chi router in different goroutines we concurrently read/write to the map which is not valid and results in panics

These other parts are Method and MethodFunc calls, which try to read from the global map. Depending on the order in which services are started the webdav or proxy service might write to the chi methodMap while another service is trying to register a route and as a result reading from the methodMap in setEndpoint ...

hm, the chi examples just use init:
https://github.com/go-chi/chi/blob/master/_examples/custom-method/main.go

func init() {
	chi.RegisterMethod("LINK")
	chi.RegisterMethod("UNLINK")
	chi.RegisterMethod("WOOHOO")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant