3

I have an API route that takes a list which 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 have decided that if the client sees that the list is too long, it will switch to sending the potentiallyLongList parameter in the POST body.

I'm wondering what the best way to do this is? The potentiallyLongList parameter shows up in several routes so I'd like to avoid having two methods for each one.

One thing I thought of is to catch all POST requests, check if they have the list in the body, and then move it to the URL and send it through Play's routing process again. Unfortunately the onRouteRequest handler in Global.scala hasn't parsed the body yet, so I can't do that.

Is there any way in an action to modify the url and then run the full request again? Or is there a better way I can solve this problem?

stevenheidel
  • 820
  • 7
  • 20

0 Answers0