Scala framework for a Rest API Server?

ApiRestScalaLift

Api Problem Overview


We are thinking on moving our Rest API Server (it is inside the web service, on Symfony PHP) to Scala for several reasons: speed, no overhead, less CPU, less code, scalability, etc. I didn't know Scala until several days ago but I've been enjoying what I've been learning these days with the Scala book and all the blog posts and questions (it's not so ugly!)

I have the following options:

  • build the Rest API Server from scratch
  • use a tiny Scala web framework like Scalatra
  • use Lift

Some things that I will have to use: HTTP requests, JSON output, MySQL (data), OAuth, Memcache (cache), Logs, File uploads, Stats (maybe Redis).

What would you recommend?

Api Solutions


Solution 1 - Api

In no particular order:

Solution 2 - Api

I'm going to recommend Unfiltered. It's an idiomatic Web framework that does things "the Scala way" and is very beautiful.

Solution 3 - Api

Take a look at Xitrum (I'm its author), it provides everything you listed. Its doc is quite extensive. From README:

Xitrum is an async and clustered Scala web framework and web server on top of Netty and Hazelcast:

  • Annotation is used for URL routes, in the spirit of JAX-RS. You don't have to declare all routes in a single place.

  • Async, in the spirit of Netty.

  • Sessions can be stored in cookies or clustered Hazelcast.

  • In-process and clustered cache, you don't need separate cache servers.

  • In-process and clustered Comet, you don't need a separate Comet server.

Solution 4 - Api

I would add two more options: akka with built-in JAX-RS support, and simply using JAX-RS directly (probably the Jersey implementation). While arguably less "Scala-y" than others (relying upon annotations to bind parameters and paths), JAX-RS is a joy to use, cleanly solving all of the problems of web service coding with minimal footprint. I've not used it via akka, I would anticipate it being excellent there, getting impressive scalability via it's continuation-based implementation.

Solution 5 - Api

Take a look at Finch, a Scala combinator library for building Finagle HTTP services. Finch allows you to construct complex HTTP endpoints out of the number of predefined basic blocks. Similarly to parser combinators, Finch endpoints are easy to reuse, compose, test, and reason about.

Solution 6 - Api

All good answers so far. One point in Lift's favor is its RestHelper, which can make it quite easy to write short, elegant API methods. In addition, all the other things you want to do should be quite straight-forward to implement in Lift. That being said, Memcache might be not be necessary.

Solution 7 - Api

A little late on the scene but I would definitely recommend using Bowler framework for creation of REST API's. It small, to the point and automatic case class conversion support!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionfesjaView Question on Stackoverflow
Solution 1 - ApioluiesView Answer on Stackoverflow
Solution 2 - ApiMax A.View Answer on Stackoverflow
Solution 3 - ApiNgoc DaoView Answer on Stackoverflow
Solution 4 - ApiDave GriffithView Answer on Stackoverflow
Solution 5 - ApiVladimir KostyukovView Answer on Stackoverflow
Solution 6 - Apipr1001View Answer on Stackoverflow
Solution 7 - Apicracked_allView Answer on Stackoverflow