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 bind uri param #1612

Merged
merged 13 commits into from Nov 22, 2018
Merged

support bind uri param #1612

merged 13 commits into from Nov 22, 2018

Conversation

thinkerou
Copy link
Member

@thinkerou thinkerou commented Oct 28, 2018

ref #846

for example:

type Uri struct {
  A string `uri:"name" binding:"required"`
  B float32 `uri:"total" binding:"required"`
  C int `uri:"age" binding:"required"`
}

func() {
  r := gin.Default()
  r.GET("/rest/n/:name/:total/:age/*other", func(c *gin.Context) {
    var uri Uri
    if err:= c.ShouldBindUri(&uri); err != nil {
      c.JSON(400, gin.H{"msg": err})
      return
    }
    ...
  }
}

Now you could use c.ShouldBindUri instead of c.Param

@thinkerou thinkerou mentioned this pull request Oct 28, 2018
@appleboy appleboy added this to the 1.4 milestone Nov 1, 2018
@codecov
Copy link

codecov bot commented Nov 2, 2018

Codecov Report

Merging #1612 into master will increase coverage by 0.1%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #1612     +/-   ##
=========================================
+ Coverage   99.29%   99.39%   +0.1%     
=========================================
  Files          40       41      +1     
  Lines        1973     1988     +15     
=========================================
+ Hits         1959     1976     +17     
+ Misses         10        9      -1     
+ Partials        4        3      -1
Impacted Files Coverage Δ
binding/binding.go 100% <ø> (ø) ⬆️
binding/uri.go 100% <100%> (ø)
binding/form_mapping.go 100% <100%> (+1.45%) ⬆️
context.go 99.5% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ec82ee...8b6849a. Read the comment docs.

@thinkerou thinkerou changed the title wip: support bind uri param support bind uri param Nov 3, 2018
@thinkerou
Copy link
Member Author

@appleboy @javierprovecho please help review the feature, thanks!

appleboy
appleboy previously approved these changes Nov 4, 2018
@martin-dos-santos
Copy link

Any news on this? Will be great to have this feature.

README.md Outdated Show resolved Hide resolved
@appleboy appleboy merged commit 521d06c into gin-gonic:master Nov 22, 2018
@thinkerou thinkerou deleted the binding branch November 22, 2018 12:49
inagacky pushed a commit to inagacky/go_gin_api that referenced this pull request Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants