Skip to content

Commit

Permalink
fix group bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chonglou committed May 11, 2017
1 parent 020d002 commit 4ead67d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ func (p *Router) Use(handlers ...HandlerFunc) {

// Crud crud
func (p *Router) Crud(path string, list []HandlerFunc, create []HandlerFunc, read []HandlerFunc, update []HandlerFunc, delete []HandlerFunc) {
p.GET(path, list...)
p.POST(path, create...)
if list != nil {
p.GET(path, list...)
}
if create != nil {
p.POST(path, create...)
}
child := path + "/{id}"
p.GET(child, read...)
p.POST(child, update...)
p.DELETE(child, delete...)
if read != nil {
p.GET(child, read...)
}
if update != nil {
p.POST(child, update...)
}
if delete != nil {
p.DELETE(child, delete...)
}
}

// Group creates a new router group
Expand Down

0 comments on commit 4ead67d

Please sign in to comment.