Grails REST中的集合(而不是成员)端点?
在rails中,有一种简单的方法可以将集合端点添加到路由。e、 gGrails REST中的集合(而不是成员)端点?,rest,grails,routes,grails-2.0,Rest,Grails,Routes,Grails 2.0,在rails中,有一种简单的方法可以将集合端点添加到路由。e、 g resources :books do member do get 'publisher' # /books/id/publisher end collection do get 'total_count' # /books/total_count end end Grails中是否有类似的方法映射total\u count端点?此处的示例()仅显示成员路由 "/books"(reso
resources :books do
member do
get 'publisher' # /books/id/publisher
end
collection do
get 'total_count' # /books/total_count
end
end
Grails中是否有类似的方法映射total\u count
端点?此处的示例()仅显示成员路由
"/books"(resources: "book") {
"/publisher"(controller:"publisher")
"/total_count"(controller: "publisher") // ??? can this work?
}
我目前正在使用Grails 2.3.4。这比我想象的要简单,不过如果有一种更规范的方法来解决这个问题,我会感谢您的反馈 基本上,我在资源端点之前定义了集合端点
class UrlMappings {
static mappings = {
"/books/total_count" (controller: "Book", action: "totalCount", method: "GET")
"/books" (resources: "Book")
}
}
到目前为止,它似乎正在发挥作用