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

chore(router): match method added to routergroup for multiple HTTP methods supporting #3464

Merged

Conversation

alirezaeftekhari
Copy link
Contributor

I added the Match method to the IRoutes interface and RouterGroup struct for supporting multiple HTTP methods with single functionality and handler.

For example, this is common to use both PUT and PATCH methods when developing RESTful APIs for updating models.
Without this method, we should repeat ourselves to handle this.

With the Match method our routing signature is like this:

r.Match([]string{http.MethodPut, http.MethodPatch}, "/", func(c *gin.Context) {
    c.String(http.StatusOK, "This handler will support both PUT and PATCH methods.")
})

@codecov
Copy link

codecov bot commented Jan 8, 2023

Codecov Report

Merging #3464 (4595e32) into master (8eb5f83) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3464   +/-   ##
=======================================
  Coverage   98.63%   98.63%           
=======================================
  Files          42       42           
  Lines        3140     3145    +5     
=======================================
+ Hits         3097     3102    +5     
  Misses         29       29           
  Partials       14       14           
Flag Coverage Δ
98.63% <100.00%> (+<0.01%) ⬆️
go-1.16 ∅ <ø> (∅)
go-1.17 98.53% <100.00%> (+<0.01%) ⬆️
go-1.18 98.53% <100.00%> (+<0.01%) ⬆️
go-1.19 98.63% <100.00%> (+<0.01%) ⬆️
macos-latest 98.63% <100.00%> (+<0.01%) ⬆️
ubuntu-latest 98.63% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
routergroup.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@appleboy appleboy added this to the v1.9 milestone Feb 5, 2023
@appleboy appleboy requested review from appleboy and thinkerou and removed request for abhiyankhanal February 6, 2023 03:19
@appleboy appleboy changed the title Match method added to routergroup for multiple HTTP methods supporting chore(router): match method added to routergroup for multiple HTTP methods supporting Feb 6, 2023
@appleboy appleboy merged commit e02ae6a into gin-gonic:master Feb 6, 2023
@alirezaeftekhari alirezaeftekhari deleted the routergroup-add-Match-method branch February 6, 2023 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants