Posts

Showing posts with the label PLAY

REST API using Play! Framework in JSON and XML Format

Play Framework  Play is heavily inspired by Ruby on Rails . Play supports both Scala and Java and enables developers to develop application faster by following convention over configurations. The following post describes how we can expose REST API Endpoints very quickly supporting multiple format like JSON XML etc using Java with Play Framework. Rest End Point Example  Say We want the List of Users to be exposed as a JSON Response with an endpoint. We will achieve the same with the following steps. Step 1: Define the Routes and Controller Mapping Step 2: Define Entity(Model Object) Step 3: Define the Controller Step 4: Start the Play Application Step1: Define the  routes (/conf/routes) Open the /conf/routes file and add the following line(s). GET /api/v1/User/details/all controllers.MyApplicationApiV1.getUserList() GET /api/v1/User/details/{userId} controllers.MyApplicationApiV1.getUserDetails(userId: Long) These entries in the routes file s...