Play 2.2.x: Request parameters in POST body to avoid exceeding URL limit

I have an API route that accepts a list that can sometimes be so long that it exceeds the URL length limit for some browsers. It looks like this:

GET /api/test Controller.test(potentiallyLongList: List[Long], other: String, ...)

      

To avoid this problem, we decided that if the client sees that the list is too long, it will switch to sending the potentialLongList parameter in the POST body.

I am wondering what is the best way to do this? The potentialLongList parameter appears in multiple routes, so I would like to avoid two methods for each one.

One thing I was thinking about was catching all POST requests, checking if they have a list in the body, then moving it to the url and submitting it again through the playback routing routine. Unfortunately the onRouteRequest handler in Global.scala hasn't parsed the body yet, so I can't do that.

Is there a way in the action to change the url and then run the full request again? Or is there a better way to solve this problem?

+3


source to share





All Articles