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.
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.
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.