fsi
fsi

Reputation: 1367

Get all methods from controller in grails 3

In this question shows to get all methods from controller in grails 2. How can I get in grails 3?

Upvotes: 1

Views: 666

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75671

It's a bit easier in Grails 3 (and Grails 2 if you only use methods for actions and no closures):

import grails.web.Action

def data = grailsApplication.controllerClasses.collect { controller ->
   [controller: controller.logicalPropertyName,
    controllerName: controller.fullName,
    actions: controller.clazz.methods.findAll { it.getAnnotation(Action) }*.name.sort()]
}

Upvotes: 3

Related Questions