What is the best way to handle different request formats for a single POST action.
So let's assume:
- we have a POST route for adding a single user (e. g. a registration)
- we have a web frontend that sends the user data as html/form data
- we have a mobile app that sends the user data as json or xml or whatever
How to do that in Play 1.3?
I have read that in newer versions of Play there is a default body parser which is able to handle different request content types and I know that you can define different response content types by using different templates (e. g. xml or json).
I think there should be only one route, e. g.
POST "user/add" UserController.createUser
I guess it would be rather bad to define different routes for each request format (e. g. "user/add/json" and "user/add/formdata" and "user/add/xml").
So a solution could be to use a single route and the controller determines which request format is used.
But how to do that in play and is this a reasonnable solution?
Would be happy about a discussion and proposals.