Response getWishList( ... ){
...
// As I don't know what is the response type, I'm using List<Wish> here...
List<Wish> wishes = userWishList.getWishList(
tokenExtractorHelper.getId(),
paginatorHelper.getPerPage(),
paginatorHelper.getPage()
);
// Let Kikaha serialize it for you! ;)
return DefaultResponse.ok().entity( wishes ).contentType( Mimes.JSON );
}
@Produces( Mimes.JSON )
Response getWishList( ... ){
...
// As I don't know what is the response type, I'm using List<Wish> here...
List<Wish> wishes = userWishList.getWishList(
tokenExtractorHelper.getId(),
paginatorHelper.getPerPage(),
paginatorHelper.getPage()
);
// Let Kikaha serialize it for you! ;)
return DefaultResponse.ok().entity( wishes );
}
@Produces( Mimes.JSON )
class WishListController {
...
Response getWishList( ... ){
...
// As I don't know what is the response type, I'm using List<Wish> here...
List<Wish> wishes = userWishList.getWishList(
tokenExtractorHelper.getId(),
paginatorHelper.getPerPage(),
paginatorHelper.getPage()
);
// Let Kikaha serialize it for you! ;)
return DefaultResponse.ok().entity( wishes );
}
If you intent to have most (or all) of your routes sending responses using the same Content-Type, you can define it on your application.conf and you will never have to worry about it any more.
# application.yml
server:
urouting:
default-content-type: "application/json"
Then you don't even have to define the mime on your Java code.
Response getWishList( ... ){
...
// As I don't know what is the response type, I'm using List<Wish> here...
List<Wish> wishes = userWishList.getWishList(
tokenExtractorHelper.getId(),
paginatorHelper.getPerPage(),
paginatorHelper.getPage()
);
// Let Kikaha serialize it for you! ;)
return DefaultResponse.ok().entity( wishes );
}
Or maybe, if you don't need to send any extra details besides of the response object, you can go even simpler like this:
// As I don't know what is the response type, I'm using List<Wish> here...
List<Wish> getWishList( ... ){
...
// Let Kikaha serialize it for you! ;)
return userWishList.getWishList(
tokenExtractorHelper.getId(),
paginatorHelper.getPerPage(),
paginatorHelper.getPage()
);
}