I have created a couple large backend APIs with Play 1.2. Now that I have created some free time for myself, I'm interested in trying to do the same with Play 2. However, it seems all the tutorials and sample projects only give use cases for dealing with form data.
When I say backend-only APIs, I'm referring to something that does not render any views that are readable to humans. More specifically, for example, a backend service to a mobile application. Most of its responses will be formatted as JSON data.
I know that the documentation shows how to parse a JSON request, but it still seems as though that is meant to be an exception. I realize I could be totally mistaken, but I just find it strange that all of Play's examples seem to use form data for interacting with controllers as opposed to external calls doing so.
Is Play 2 still the right choice for this use case? If so, are there any good sample projects or tutorials for that?
Play for Scala has an entire chapter (Chapter 8) dedicated to this topic (in the context of building a single-page web application). Whether a technology is "right" for a particular need is a matter of judgment, but there is no question Play supports the REST API use case.
Play has sophisticated mechanisms for reading, validating, and writing JSON (with all kinds of custom formatting capability). You also have the typical Play benefits of asynchronous reactive programming to enable scaling to a large number of clients
The only real tricky thing is how you handle authentication if that matters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With