mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 13:02:14 +08:00
rename Read to List, and add Take support
This commit is contained in:
parent
d5adf63fa1
commit
d5a0029191
14
gin.go
14
gin.go
@ -210,8 +210,11 @@ func (group *RouterGroup) HEAD(path string, handlers ...HandlerFunc) {
|
|||||||
type CreateSupported interface {
|
type CreateSupported interface {
|
||||||
CreateHandler(*Context)
|
CreateHandler(*Context)
|
||||||
}
|
}
|
||||||
type ReadSupported interface {
|
type ListSupported interface {
|
||||||
ReadHandler(*Context)
|
ListHandler(*Context)
|
||||||
|
}
|
||||||
|
type TakeSupported interface {
|
||||||
|
TakeHandler(*Context)
|
||||||
}
|
}
|
||||||
type UpdateSupported interface {
|
type UpdateSupported interface {
|
||||||
UpdateHandler(*Context)
|
UpdateHandler(*Context)
|
||||||
@ -229,8 +232,11 @@ func (group *RouterGroup) CRUD(path string, resource interface{}) {
|
|||||||
if resource, ok := resource.(CreateSupported); ok {
|
if resource, ok := resource.(CreateSupported); ok {
|
||||||
group.POST(path, resource.CreateHandler)
|
group.POST(path, resource.CreateHandler)
|
||||||
}
|
}
|
||||||
if resource, ok := resource.(ReadSupported); ok {
|
if resource, ok := resource.(ListSupported); ok {
|
||||||
group.GET(path, resource.ReadHandler)
|
group.GET(path, resource.ListHandler)
|
||||||
|
}
|
||||||
|
if resource, ok := resource.(TakeSupported); ok {
|
||||||
|
group.GET(path+"/:id", resource.TakeHandler)
|
||||||
}
|
}
|
||||||
if resource, ok := resource.(UpdateSupported); ok {
|
if resource, ok := resource.(UpdateSupported); ok {
|
||||||
group.PUT(path+"/:id", resource.UpdateHandler)
|
group.PUT(path+"/:id", resource.UpdateHandler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user