As a spray newbie and general computer enthusiast I thought of playing around with spray.io and my Raspberry Pi (RPI) at home. In this blog post I want to show a small example of how to get started with spray.io on the RPI.
A few days ago the folks at techempower published round 5 of their well-received current series of web framework benchmarks, the first one in which spray participates. The techempower benchmark consist of a number of different test scenarios exercising various parts of a web framework/stack, only one of which we have supplied a spray-based implementation for: the “JSON serialization” test. The other parts of this benchmark target framework layers (like database access), which spray intentionally doesn’t provide.
In this post I’d like to shine some light on one particular implementation technique that is used extensively under the hood of sprays routing DSL and which has turned out as a very valuable tool in our “pattern toolbox”. It solves certain kinds of problems in Scala API design and DSL development, especially (but not only) with regard to overloaded methods. We call it the magnet pattern and, hopefully, by the time you’ve finished reading this post this name will make sense to you.
During the writing and continuous improvement of the spray documentation we’ve come across multiple things that don’t quite fit the reference-type nature of the rest of this site. Sometimes this is because the material is kind of cross-cutting, like the description of a general technique used in several places of the spray implementation, and sometimes because it’s more of a one-off highlighting of a specific feature or behavior. For this type of content a blog-style channel appears to be the better format, which is why we hereby solemnly unveil the official “spray blog”. ***tadaa***