Required Parameters plugin for the Grails framework
Groovy Java
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
grails-app
src/java/de/bowstreet/grails/plugins
test/unit/grails/required/parameters
.gitignore
README.md
RequiredParametersGrailsPlugin.groovy
application.properties

README.md

grails-required-parameters

Required Parameters plugin for the Grails framework.

This plugin simplifies working with Grails controller actions as it defines a simple annotation-style method to check whether all necessary parameters of an action are present.

How to use

When you install the plugin, you get a new annotation-type: de.bowstreet.grails.plugins.RequiredParameters. To use it, you simply add it to your desired action-method (note: only methods as actions are supported right now) like this:

import de.bowstreet.grails.plugins.RequiredParameters

public class FooController {

    @RequiredParameters(['id', 'anotherParam'])
    def bar() {
        // action logic...
    }

}

The request will only be forwarded to the controller if all the given conditions are met. If a required parameter is missing, the user will get an HTTP 400 BAD REQUEST.

Extend

Please use this plugin as a starting point for your own purposes - its very simple in nature right now, because that's what we need right now - but we plan to expand it in the future. Look at the issues section if you want to see what's already planned.