I didn’t find this anywhere – can i tell Play! that a specific controller method should (only) be accessed via HTTP POST?
Something like the HttpPost attribute in C#’s Asp.Net MVC?
public class MyController extends Controller {
@Post
public void addPerson(String name, String address) {
}
}
Update – I don’t understand what adding a POST route do:
- A POST request will work without adding such a route.
- Because the method is still catched by the “Catch all” GET rule, even adding the POST route won’t prevent GET requests to this method.
You could do it this way:
But keep in mind that your code and your routes file might be out of sync.
Also, you can use Groovy code inside the routes file, so no need for duplication.