curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework REST/RESTful web services.
If you ever need some good ScalaJ-HTTP examples, see the test files in the project, including this HttpBinTest.scala file. That file currently shows a number of good ScalaJ-HTTP examples, including GET, POST, redirect examples with Scala.
See that page for a full list of examples, but for my own use, here are a few of them.
I was looking for a good way to access XML resources (like RSS feeds) in Scala, and I currently like the idea of using ScalaJ-HTTP to access the URL and download the XML content, and then using the Scala XML library to process the XML string I download from the URL.
This example Scala program shows my current approach:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 15.14, “How to write a GET request web service with the Play Framework.”
You want to create a
GET request web service using the Play Framework, such as returning a JSON string when the web service URI is accessed.
When working with RESTful web services, you’ll typically be converting between one or more model objects and their JSON representation.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 15.9, “How to write a simple HTTP GET request client in Scala.”Back to top
You want an HTTP client you can use to make
GET request calls.
There are many potential solutions to this problem. This recipe demonstrates three approaches:Back to top
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a short recipe, Recipe 15.7, “How to access Scalatra web service GET parameters.”
When creating a Scalatra web service, you want to be able to handle parameters that are passed into a method using a
If you want to let parameters be passed into your Scalatra servlet with a URI that uses traditional
& characters to separate data elements, like this:
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 15.5, “How to create simple web services with Scalatra.”
You want to be able to build new web services with Scalatra, a lightweight Scala web framework similar to the Ruby Sinatra library.
The recommended approach to create a new Scalatra project is to use Giter8, a great tool for building SBT directories for new projects.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is one of the shortest recipes, Recipe 11.17, “How to Access Map Values in Scala”
You want to access individual values stored in a map. You may have tried this and run into an exception when a key didn’t exist, and want to see how to avoid that exception.
Given a sample map:
When you first work with a Sencha ExtJS or Touch Store and Proxy, you’ll quickly find that when you create GET and POST REST services, by default the store/proxy adds extra parameters to the end of the URLs you’re accessing.