Reading out all actions in a Grails-Controller

前端 未结 5 578
别跟我提以往
别跟我提以往 2021-01-02 20:53

I need to read out all available actions from any controller in my web-app. The reason for this is an authorization system where I need to give users a list of allowed actio

5条回答
  •  旧巷少年郎
    2021-01-02 21:42

    I had to pull a list of all controllers and their respective URI. This is what I did on a grails 3.1.6 application.

    grailsApplication.controllerClasses.each { controllerArtefact ->
                def controllerClass = controllerArtefact.getClazz()
                def actions = controllerArtefact.getActions()
                actions?.each{action->
                    def controllerArtefactString = controllerArtefact.toString()
                    def controllerOnly = controllerArtefactString.split('Artefact > ')[1]
                    println "$controllerOnly >>>> $controllerOnly/${action.toString()}"
                }
            }
    

提交回复
热议问题