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

Support Router scopeed RegisterMethod #686

Open
wenerme opened this issue Dec 11, 2021 · 2 comments
Open

Support Router scopeed RegisterMethod #686

wenerme opened this issue Dec 11, 2021 · 2 comments

Comments

@wenerme
Copy link

wenerme commented Dec 11, 2021

Current RegisterMethod will register to global, but some handle do not expected the unknown methods, e.g. a webdav expected PROPFIND, but all other handler are not.

@pkieltyka
Copy link
Member

can you explain with an example? I'm having a difficult time understanding what is the issue

@wenerme
Copy link
Author

wenerme commented Jan 8, 2022

now

chi.RegisterMethod("SEARCH")
r := chi.NewRouter()
r.HandleFunc("/api/v1", func(writer http.ResponseWriter, request *http.Request) {
	// don't expect SEARCH here
	// request.Method
})
r.HandleFunc("/api/v1/webdav", func(writer http.ResponseWriter, request *http.Request) {
	// expect SEARCH here
})

propose

webdav:=r.With()
// RegisterMethod only affect this route
webdav.RegisterMethod("SEARCH")
webdav.HandleFunc("/api/v1/webdav", func(writer http.ResponseWriter, request *http.Request) {
	// expect SEARCH here
})

webdav support alot methods

ACL, CANCELUPLOAD, CHECKIN, CHECKOUT, COPY, DELETE, GET, HEAD, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL

register to global will affect other handler's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants