From d5a00291919066179d0c0f9f670305ab4424407f Mon Sep 17 00:00:00 2001 From: Yuya Yabe Date: Fri, 22 Aug 2014 01:49:35 -0700 Subject: [PATCH] rename Read to List, and add Take support --- gin.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gin.go b/gin.go index c7a19dda..749ee3a2 100644 --- a/gin.go +++ b/gin.go @@ -210,8 +210,11 @@ func (group *RouterGroup) HEAD(path string, handlers ...HandlerFunc) { type CreateSupported interface { CreateHandler(*Context) } -type ReadSupported interface { - ReadHandler(*Context) +type ListSupported interface { + ListHandler(*Context) +} +type TakeSupported interface { + TakeHandler(*Context) } type UpdateSupported interface { UpdateHandler(*Context) @@ -229,8 +232,11 @@ func (group *RouterGroup) CRUD(path string, resource interface{}) { if resource, ok := resource.(CreateSupported); ok { group.POST(path, resource.CreateHandler) } - if resource, ok := resource.(ReadSupported); ok { - group.GET(path, resource.ReadHandler) + if resource, ok := resource.(ListSupported); ok { + group.GET(path, resource.ListHandler) + } + if resource, ok := resource.(TakeSupported); ok { + group.GET(path+"/:id", resource.TakeHandler) } if resource, ok := resource.(UpdateSupported); ok { group.PUT(path+"/:id", resource.UpdateHandler)