This is an Activator template showing how to use Play framework Iteratees to build a custom body parser in Scala, using as an example an MP3 file metadata parser.
First make sure you already have Typesafe's Activator installed. We recommend you install the mini-package so only the required dependencies are loaded when you launch the project.
Then, cd into the project and run
activator ui
and follow the tutorial.
Throughout this tutorial we will explore how to use Iteratees, a nifty abstraction provided in the Play framework to handle streams reactively.
According to the manual:
Progressive Stream Processing and manipulation is an important task in modern Web Programming, starting from chunked upload/download to Live Data Streams consumption, creation, composition and publishing through different technologies including Comet and WebSockets.
Inside the Play framework, Iteratees are used among other things to build body parsers, which consume the raw incoming data and transform it appropriately so that it is delivered to an Action, that receives it aptly wrapped in a [Request](http://www.playf ramework.com/documentation/2.3.x/api/scala/index.html#play.api.mvc.Request). The Request's body will be typed according to the transformed data and can contain for example json, xml, multipart form data or a URL-encoded form.
You can build your own custom body parsers to pre-process incoming data before delivering it to an Action, and that's exactly what we're gonna do here.
This software is issued under the Apache 2 license.