TRENDING NEWS

POPULAR NEWS

How To Write A Rest Api In Play Framework

Which Scala framework is the best for REST API development?

There are basically two groups of choices depending on how much FP you are willing to take (I discuss this peculiarity of the Scala ecosystem here - The Scala ecosystem).First, the mainstream Scala. For the majority of people, the best bet is probably the Play Framework. It’s stable, well designed, very well documented and extremely approachable. Also, there is akka-http, which is also being maintained by Lightbend.If you’re more keen on FP, then you should check out two Typelevel projects - Finch and htt4s. Both are quite minimalistic, both are built with functional purity in mind. Finch is built on top of Twitter Finagle, http4s is built on top of scalaz-stream (but it will switch to FS2 in the future).

How do I make API calls between React and the Play Framework?

Assuming rect is separate app. i.e. rect app is on port no 3000 & play backend on port 9000.To call play api. You need to set CORS. For each requeat, except GET prelight request will execute first. i. e. OPTION request. This request should be handle at back end. For More information read about CORS.Thaks for A2A.

Anyone build a web API in Java play framework and hosted it in Windows + Tomcat platform?

No need to have Play Framework on Tomcat ! Because tomcat is a servlet container.You can get fully working example here which creates web api ( rest api ) using Java Standard known as JAX-RS.szymex/Embedded-Jetty-RESTEasy-Guice-Example

What framework or library should I use to develop a REST API, Django REST, Ruby on Rails, Play (Scala), or Spray (Scala)?

Whichever allows you to do what you want easiest. Each framework that you’ve listed has pros and cons, each one is quite powerful in some areas, and each one is lacking in others. Honestly, its completely up to you: there is no one-size-fits-all solution. Depending on what you are familiar with already and what you’re doing, any one of these could be awesome for your project. Do what I do: research an introductory tutorial on each, and compare what the tutorials do. If there is one framework whose tutorial has a clear path to what you want to do, choose that one: its abilities will quickly match your goals.

Is it overkill to create a simple CMS website using Scala and Play framework?

I will start by saying that if there is an existing CMS like Wordpress or Joomla that  will do, then writing your own CMS in any language would be an overkill. An established CMS will give you a solid start and they are all customizable by plugins.However, if your requirements lead you to roll your own CMS then writing it in Scala and Play is not any different than building it with say, Ruby on Rails or Django.As Ngoc Dao wrote, if you need real time updates then Play is an excellent choice. At TrueAccord (company), we built our own in-house CMS in Scala/AngularJS which is tightly integrated with our data-model and our unique approach to data analytics. Using Scala as a backend for our CMS made it easy to express business rules and data in a type-safe manner. Our CMS contains both web pages and emails that make use of a large number of variables. There are a lot of business rules that we run through before choosing the right content, as well as data that are being passed through the content. Being able to formulate it precisely and have the compiler go through it all was a huge win for us. Clearly, this could have  been accomplished using any other web framework and language, but Scala proved to be great language for our use case and Play made it easy to build the internal RESTful APIs and serving platform.

I need to develop a RESTful API using Scala, Play and Akka. I'm new to all three technologies. Is there a guide that would help me work through this?

Actually, if you were to adjust your stack, I'd suggest Scalatra rather than Spray, simply because of it being more approachable. You don't say what experience you do have, but if you have experience with Ruby's Sinatra, Scalatra is easy to pick up. Even if you don't, it's easier than Spray.Nothing against spray, I do use it myself for restful APIs, but I wouldn't want it to be my first introduction to Scala and Akka.All other things being equal, Play is meant for right web user interfaces, whereas RESTful APIs would be happier with minimalist frameworks. But this is simply my opinion. Play will do REST APIs just fine.

What are some good tutorials for the Play framework (Java)?

I went through the tutorials on play framework 2.2 and they great,even on the play 2.2 download zip contains those tutorials on the folder called sample. The sources of both java and scala are there.You can find the old package for play framework with sample project in it from this link https://www.playframework.com/do....And below is more information if you want to learn more about play framework http://www.ybrikman.com/writing/...

Is Play framework a good option to build rest services for Android?

Yes it is one of the good options , as it provides a capability of building rest API with easy ,follow this. Tutorial and see how easy is to build a rest service in play framework REST API with Play Framework in Java | Baeldung .

When developing a RESTful API service what would you prefer: a full blown web framework such as Ruby on Rails, Scala Play framework etc. or a micro container such as Sinatra, Spary.io/Scalatra etc and what are the arguments?

Much of the power of full blown web frameworks like RoR and Django lie in their template and data access layers.  Since we are talking about a RESTful API service, the template layer is obviously not needed.  However, the DB layer might still provide considerable benefits, depending on the specific goals of your service.It's important to realize that a well-designed framework like Django is very modular; you can use only the parts you want.  A common misconception is that a full-blown framework is somehow slower when used to do simple tasks, but this makes little sense once you realize only a small part of the codebase is being run at any given time.In any case, I would go with a complex and mature framework than a simpler but immature framework any day.  The strength of the community, built-in security, and quality of documentation will quickly outweigh any potential "nimbleness" you get out of a simple framework.  YMMV of course.Finally, the performance of a RESTful service is seldom determined by the choice of framework.  It's usually the I/O part that is the bottleneck: reading/writing data to/from database, network IO, etc.  Extensive caching and smart DB design are usually the most effective way to tackle performance problems, but that's another topic :)EDIT:If you indeed decide to use Django, I strongly recommend taking a look at Django REST framework, which is a plugin for Django that makes it easy to write RESTful services.

What is the best approach to offer a secure CRUD restful API through Play framework?

I would definitely vouch for auth-token based authentication.When a user is authenticated, you can generate random auth-token and send it via response headers. This token you can store at your end to look up and uniquely identify the user. You can configure the keep alive time of the token. For all subsequent requests made to your server, you can check against the token.Using tokens also greatly soothens the heterogeneous platforms effects in case you want to consume the same APIs through mobiles and web applications.

TRENDING NEWS