Support for CRUD operations with http’s POST, GET, PUT and DELETE methods.These will most likely apply for many other rest services as well: In this blog I’ll decipher it for you and show how easy it is to test restful services with mere oneliners.īefore we dive into Dispatch’s mysterious DSL let’s look at the prerequisites I had for testing my restful service. This DSL, however, is not very well documented and rather hard to decipher due to it’s heavy usage of symbolic method names but nevertheless highly appealing when understood. My search led me to Dispatch, which is a highly compact Scala DSL wrapper around Apache’s reliable HttpClient. JSON support is possible in akka-http by the use of Jackson, an external artifact (see JSON Support for details): sbt val AkkaHttpVersion = "10.5.For testing a restful service API I was looking for a lean library, which would allow me to test CRUD operations of rest services with as little code as possible. Implementation platform(":akka-http-bom_$ The modules, however, do not depend on akka-actor or akka-stream, so the user is required to choose an Akka version to run against and add a manual dependency to akka-stream of the chosen version. Akka HTTP is compatible with Akka >= 2.7.0 and future Akka 2.x versions that are released during the lifetime of Akka HTTP 10.4.x. Using Akka HTTPĪkka HTTP is provided as independent modules from Akka itself under its own release cycle. If you come from Play and want to try Akka HTTP, we collected a side-by-side comparison to show how some Play routing features map to the Akka HTTP routing DSL. On the other hand, if you prefer to build your applications with the guidance of a framework, you should give Play Framework or Lagom a try, which both use Akka internally. Therefore you normally don’t build your application “on top of” Akka HTTP, but you build your application on top of whatever makes sense and use Akka HTTP merely for the HTTP integration needs. Akka HTTP is made for building integration layers based on HTTP and as such tries to “stay on the sidelines”. Also, you probably won’t benefit from the possibly existing browser-specific framework components like view templating, asset management, JavaScript- and CSS generation/manipulation/minification, localization support, AJAX support, etc.Īkka HTTP was designed specifically as “not-a-framework”, not because we don’t like frameworks, but for use cases where a framework is not the right choice. ![]() In this case the application architecture should be dictated by what makes sense for the core not the interface layer. However, if your application is not primarily a web application because its core is not browser-interaction but some specialized maybe complex business service and you are merely trying to connect it to the world via a REST/HTTP interface a web-framework might not be what you need. Being able to rely on best-practice architecture like this can be a great asset for getting things done quickly. The framework makers have chosen one “proven” way of designing such applications and let you “fill in the blanks” of a more or less flexible “application-template”. As such frameworks work best if you choose them before you start application development and try to stick to the framework’s “way of doing things” as you go along.įor example, if you are building a browser-facing web application it makes sense to choose a web framework and build your application on top of it because the “core” of the application is the interaction of a browser with your code on the web-server. In a way a framework is like a skeleton onto which you put the “flesh” of your application in order to have it come alive. It comes with a lot of decisions already pre-made and provides a foundation including support structures that lets you get started and deliver results quickly. As such it regards itself as a suite of libraries rather than a framework.Ī framework, as we’d like to think of the term, gives you a “frame”, in which you build your application. ![]() PhilosophyĪkka HTTP has been driven with a clear focus on providing tools for building integration layers rather than application cores. This means that, if you have trouble achieving something using a high-level API, there’s a good chance that you can get it done with a low-level API, which offers more flexibility but might require you to write more application code. ![]() You get to pick the API level of abstraction that is most suitable for your application. While interaction with a browser is of course also in scope it is not the primary focus of Akka HTTP.Īkka HTTP follows a rather open design and many times offers several different API levels for “doing the same thing”. ![]() It’s not a web-framework but rather a more general toolkit for providing and consuming HTTP-based services. The Akka HTTP modules implement a full server- and client-side HTTP stack on top of akka-actor and akka-stream.
0 Comments
Leave a Reply. |