Play framework and REST
Well, I love Play so far and I was hoping to prod the community for success and failure stories of trying t开发者_如何学编程o develop a great REST app. I have extensive experience with Django and thought of applying some methodologies from http://django-tastypie.readthedocs.org/en/latest/?redir API creation package to Play.
Have you found a good equivalent to exposing Models through and API package with flexible settings for throttling, data output whitelisting, data output formatting, automatic api url routes and so on ?
A few time ago, there has been a discussion about exposing Models on play google group. It was quite a picky discussion because the audience was completely cut in 2 groups:
- the ones who would really like this feature and want it absolutely.
- the ones who say it's a really bad (even dangerous) manner to expose directly your model on presentation layer because it break the MVC design and expose directly your business data with potential security or data integrity breaches etc...
I'm not in any group and I simply consider the question objectively...
When looking at this Django API, I think that it's not much a problem if you can control how your model is exposed and what exactly is exposed.
But I don't know anything doing it out of the box in Play!... I don't know if the guy who began the discussion evoked here before has ever finished his module... Anyway, the CRUD module already does something like that because it introspects your model fields to expose a CRUD interface... so exposing it as REST would just be a matter of presentation (and some work) IMHO.
Here you have a couple of module that may help you build rest web services from play! apps
RESTEasy play module
The RESTEasy Play module allows you to define JAX-RS RESTful web services in the Play framework using RESTEasy.
and
RESTEasy-CRUD Play module
The RESTEasy-CRUD Play module allows you to automatically generate a set of CRUD JAX-RS RESTful web services in the Play framework using RESTEasy.
I hope it helps
精彩评论