I have a Rest API with Grail 2.5.6 and I am implementing some improvements and best practices. In this case I need to implement the rule:
I know that I can configure the UrlMapping file for each method and I solve it. But I understand that there should be some notation on the method that allows me to conigure was URI.
In the grails 4.0 documentation I see the following example:
@Get("/search?limit=25&media=music&entity=album&term={term}")
SearchResult search(String term)
For Grail 2.5.6 is there an alternative similar to @Get ?
Finally with trial and error, I found the solution. I leave you the example of how it was and how the controller turned out.
Before:
class LoginController {
static allowedMethods = [userInfo: 'GET']
def userInfo() {}
}
Now:
class LoginController {
static allowedMethods = ['user-info': 'GET']
def "user-info"() {} // <-- here is the change
}
By defining the method name in quotation marks I could implement kebab-case .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.