Skip to content

feat(echo): add dynamic path support for echo endpoint#271

Merged
stefanprodan merged 2 commits intostefanprodan:masterfrom
jjchambl:feature/add_dynamic_paths
Jun 22, 2023
Merged

feat(echo): add dynamic path support for echo endpoint#271
stefanprodan merged 2 commits intostefanprodan:masterfrom
jjchambl:feature/add_dynamic_paths

Conversation

@jjchambl
Copy link
Copy Markdown
Contributor

@jjchambl jjchambl commented Jun 7, 2023

This pull request seeks to add dynamic path support for both the echo and api/echo endpoints, so that echo/test is also routed to the echo handler, as is echo/test/test.

In addition, I've added support for PUT operations to this endpoint.

Comment thread pkg/api/server.go Outdated
Comment on lines +103 to +104
s.router.HandleFunc("/echo", s.echoHandler).Methods("POST,PUT")
s.router.HandleFunc("/echo/{echo:.*}", s.echoHandler).Methods("POST,PUT")
Copy link
Copy Markdown

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?
Suggested change
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)

Comment thread pkg/api/server.go Outdated
Comment on lines +123 to +124
s.router.HandleFunc("/api/echo", s.echoHandler).Methods("POST,PUT")
s.router.HandleFunc("/api/echo{echo:.*}", s.echoHandler).Methods("POST,PUT")
Copy link
Copy Markdown

@merusso merusso Jun 7, 2023

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:.*})

Copy link
Copy Markdown
Contributor Author

@jjchambl jjchambl Jun 8, 2023

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.

@jjchambl
Copy link
Copy Markdown
Contributor Author

@stefanprodan bumping this PR; happy to make changes as needed.

Copy link
Copy Markdown
Owner

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks @jjchambl

@stefanprodan stefanprodan merged commit 7d13025 into stefanprodan:master Jun 22, 2023
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

Successfully merging this pull request may close these issues.

3 participants