Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbirthday committed Nov 10, 2021
1 parent 660bf21 commit ce9b9f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions routerx/apigroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,44 @@ func (r *ApiGroup) Use(middleware ...gin.HandlerFunc) *ApiGroup {
}

func (r *ApiGroup) Handle(httpMethod, relativePath string, fn interface{}) *ApiGroup {
r.group.Handle(httpMethod, relativePath, RequestParseJson(fn))
r.group.Handle(httpMethod, relativePath, RequestBind(fn))
return r
}

func (r *ApiGroup) Any(relativePath string, fn interface{}) *ApiGroup {
r.group.Any(relativePath, RequestParseJson(fn))
r.group.Any(relativePath, RequestBind(fn))
return r
}
func (r *ApiGroup) POST(relativePath string, fn interface{}) *ApiGroup {
r.group.POST(relativePath, RequestParseJson(fn))
r.group.POST(relativePath, RequestBind(fn))
return r
}
func (r *ApiGroup) GET(relativePath string, fn interface{}) *ApiGroup {
r.group.GET(relativePath, RequestParseJson(fn))
r.group.GET(relativePath, RequestBind(fn))
return r
}

func (r *ApiGroup) DELETE(relativePath string, fn interface{}) *ApiGroup {
r.group.DELETE(relativePath, RequestParseJson(fn))
r.group.DELETE(relativePath, RequestBind(fn))
return r
}

func (r *ApiGroup) PATCH(relativePath string, fn interface{}) *ApiGroup {
r.group.PATCH(relativePath, RequestParseJson(fn))
r.group.PATCH(relativePath, RequestBind(fn))
return r
}

func (r *ApiGroup) PUT(relativePath string, fn interface{}) *ApiGroup {
r.group.PUT(relativePath, RequestParseJson(fn))
r.group.PUT(relativePath, RequestBind(fn))
return r
}

func (r *ApiGroup) OPTIONS(relativePath string, fn interface{}) *ApiGroup {
r.group.OPTIONS(relativePath, RequestParseJson(fn))
r.group.OPTIONS(relativePath, RequestBind(fn))
return r
}

func (r *ApiGroup) HEAD(relativePath string, fn interface{}) *ApiGroup {
r.group.HEAD(relativePath, RequestParseJson(fn))
r.group.HEAD(relativePath, RequestBind(fn))
return r
}
6 changes: 3 additions & 3 deletions routerx/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"strings"
)

func RequestParseJson(fn interface{}) gin.HandlerFunc {
return requestParseJson(fn)
func RequestBind(fn interface{}) gin.HandlerFunc {
return requestBind(fn)
}

func requestParseJson(fn interface{}) gin.HandlerFunc {
func requestBind(fn interface{}) gin.HandlerFunc {
fnv := reflect.ValueOf(fn)
if fnv.Kind() != reflect.Func {
return nil
Expand Down

0 comments on commit ce9b9f8

Please sign in to comment.