Skip to content

Commit

Permalink
chore: add more comment
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkgos committed Apr 25, 2024
1 parent 0cff626 commit d5e41d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
11 changes: 8 additions & 3 deletions ginp/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,23 @@ func (cy *GinCarry) SetTranslateError(e transport.ErrorTranslator) *GinCarry {
cy.translate = e
return cy
}

// Deprecated: Use BindURI not need this.
func (*GinCarry) WithValueUri(req *http.Request, params gin.Params) *http.Request {
return transportHttp.WithValueUri(req, params)
}

// Deprecated: Use BindURI not need this.
func (*GinCarry) BindUri(c *gin.Context, v any) error {
return c.ShouldBindUri(v)
}

func (*GinCarry) Bind(c *gin.Context, v any) error {
return c.ShouldBind(v)
}
func (*GinCarry) BindQuery(c *gin.Context, v any) error {
return c.ShouldBindQuery(v)
}
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)
Expand Down
10 changes: 7 additions & 3 deletions ginp/ginp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,22 @@ func NewCarry(opts ...Option) *Carry {
return cy
}

// Deprecated: Use BindURI not need this.
func (cy *Carry) WithValueUri(req *http.Request, params gin.Params) *http.Request {
return transportHttp.WithValueUri(req, params)
}

// Deprecated: Use BindURI not need this.
func (cy *Carry) BindUri(c *gin.Context, v any) error {
return cy.encoding.BindUri(c.Request, v)
}

func (cy *Carry) Bind(c *gin.Context, v any) error {
return cy.encoding.Bind(c.Request, v)
}
func (cy *Carry) BindQuery(c *gin.Context, v any) error {
return cy.encoding.BindQuery(c.Request, v)
}
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)
}
Expand Down
11 changes: 6 additions & 5 deletions transport/http/carrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ type Carrier interface {
//
// 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.
Bind(*gin.Context, any) error
// BindQuery binds the passed struct pointer using the query codec.Marshaler.
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

// Bind checks the Method and Content-Type to select codec.Marshaler automatically,
// Depending on the "Content-Type" header different bind are used.
Bind(*gin.Context, any) error
// BindQuery binds the passed struct pointer using the query codec.Marshaler.
BindQuery(*gin.Context, any) error
// BindUri binds the passed struct pointer using the uri codec.Marshaler.
BindURI(*gin.Context, url.Values, any) error
// Error encode error response.
Expand Down

0 comments on commit d5e41d0

Please sign in to comment.