- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(echo): add dynamic path support for echo endpoint #271
feat(echo): add dynamic path support for echo endpoint #271
Conversation
pkg/api/server.go
Outdated
s.router.HandleFunc("/echo", s.echoHandler).Methods("POST,PUT") | ||
s.router.HandleFunc("/echo/{echo:.*}", s.echoHandler).Methods("POST,PUT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions:
- What about using PathPrefix() to allow "/echo/{anyPath}"?
- What about accepting all HTTP methods, e.g. not restricting these paths to specific methods?
s.router.HandleFunc("/echo", s.echoHandler).Methods("POST,PUT") | |
s.router.HandleFunc("/echo/{echo:.*}", s.echoHandler).Methods("POST,PUT") | |
s.router.Path("/echo").HandlerFunc(s.echoHandler) | |
s.router.PathPrefix("/echo/").HandlerFunc(s.echoHandler) |
pkg/api/server.go
Outdated
s.router.HandleFunc("/api/echo", s.echoHandler).Methods("POST,PUT") | ||
s.router.HandleFunc("/api/echo{echo:.*}", s.echoHandler).Methods("POST,PUT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be consistent with the path patterns used above (currently api/echo{echo:.*}
vs /echo/{echo:.*}
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be consistent with the path patterns used above (currently api/echo{echo:.} vs /echo/{echo:.})
This is consistent with the previous route paths; both /api/echo
and /echo
were exposed previously.
@stefanprodan bumping this PR; happy to make changes as needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @jjchambl
This pull request seeks to add dynamic path support for both the
echo
andapi/echo
endpoints, so thatecho/test
is also routed to the echo handler, as isecho/test/test
.In addition, I've added support for PUT operations to this endpoint.