Iain Hull

A Simple REST DSL Part 3

Processing http responses.

In part 2, I showed how to describe and execute REST requests with a simple descriptive syntax, but it completely ignored processing the response. This should be as simple as making the request. First let’s simplify access to the components of the response. You can create a returning method to execute the Request and extract one or more values from the Response. For example: {% highlight scala %} val personJson = “”"{ “name”: “Jason” }""" RequestBuilder() url “http://api.

A Simple REST DSL Part 2

Using a builder to construct a DSL.

In part 1, I showed the builder pattern can improve code readability and composibility of REST requests. Now, let’s discover how the builder can be used as the basis for a simple DSL. First you need to decide what words or phrases to use to bootstrap the request DSL. Do this by describing some sample requests in simple English and looking for patterns, for example: Get from url http://api.rest.org/person/ Post personJson to url http://api.

A Simple REST DSL Part 1

Creating a DSL for testing REST based Web services.

I spend a lot of time working on REST based Web services. Writing system tests for these can lead to a lot of boiler-plate code which is tedious to read and write and obscures the intention of the tests. When it comes to removing boiler plate, Scala is your friend, so lets see what you can do to improve your tests. I want to explore internal Domain Specific Languages (DSLs), an area that Scala excels at, but first I want to look at the Builder pattern.

Akka Dynamo 1

First experiments with implementing Dynamo in Akka.

http://lethain.com/hands-on-review-of-the-dynamo-paper/ Setup Install sbt brew install sbt Create an akka project mkdir akka-dynamo cd akka-dynamo mkdir -p src/main/scala mkdir -p src/test/scala Create build.sbt name := "Akka Dynamo" scalaVersion := "2.9.2" resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" retrieveManaged := true libraryDependencies ++= Seq("com.typesafe.akka" % "akka-actor" % "2.0.3", "com.typesafe.akka" % "akka-remote" % "2.0.3", "com.typesafe.akka" % "akka-testkit" % "2.0.3" % "test", "org.specs2" %% "specs2" % "1.9" % "test", "junit" % "junit" % "4.5" % "test") The messages Scala is a strongly typed language so the message types have to be defined.