Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed Apr 25, 2024
1 parent c13d301 commit 27e9be6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ginp/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
stdErrors "errors"
"net/http"
"net/url"

"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
Expand Down Expand Up @@ -47,6 +48,11 @@ func (*GinCarry) BindQuery(c *gin.Context, v any) error {
func (*GinCarry) BindUri(c *gin.Context, v any) error {
return c.ShouldBindUri(v)
}

func (*GinCarry) BindURI(c *gin.Context, _ url.Values, v any) error {
return c.ShouldBindUri(v)
}

func (cy *GinCarry) Error(c *gin.Context, err error) {
if cy.translate != nil {
err = cy.translate.Translate(err)
Expand Down
4 changes: 4 additions & 0 deletions ginp/ginp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
stdErrors "errors"
"net/http"
"net/url"

"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
Expand Down Expand Up @@ -68,6 +69,9 @@ func (cy *Carry) BindQuery(c *gin.Context, v any) error {
func (cy *Carry) BindUri(c *gin.Context, v any) error {
return cy.encoding.BindUri(c.Request, v)
}
func (cy *Carry) BindURI(c *gin.Context, raws url.Values, v any) error {
return cy.encoding.BindURI(raws, v)
}

func (cy *Carry) Error(c *gin.Context, err error) {
if cy.translate != nil {
Expand Down
7 changes: 7 additions & 0 deletions transport/http/carrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package http
import (
"context"
"net/http"
"net/url"

"github.com/gin-gonic/gin"
)
Expand All @@ -12,6 +13,8 @@ type ctxCarrierKey struct{}
// Carrier is an HTTP Carrier.
type Carrier interface {
// WithValueUri sets the URL params for the given request.
//
// Deprecated: Use BindURI not need this.
WithValueUri(*http.Request, gin.Params) *http.Request
// Bind checks the Method and Content-Type to select codec.Marshaler automatically,
// Depending on the "Content-Type" header different bind are used.
Expand All @@ -20,7 +23,11 @@ type Carrier interface {
BindQuery(*gin.Context, any) error
// BindUri binds the passed struct pointer using the uri codec.Marshaler.
// NOTE: before use this, you should set uri params in the request context with RequestWithUri.
//
// Deprecated: Use BindURI not need this.
BindUri(*gin.Context, any) error
// Deprecated: Use BindURI not need this.
BindURI(*gin.Context, url.Values, any) error
// Error encode error response.
Error(*gin.Context, error)
// Render encode response.
Expand Down

0 comments on commit 27e9be6

Please sign in to comment.