-
Book Overview & Buying
-
Table Of Contents
Lift Application Development Cookbook
By :
In this recipe, we will learn how to build URLs to respond to GET requests. In other words, we will learn how to serve data to the clients of your API. This means that you will be able to create a REST URL, where you can fetch a collection from data of a given resource—data about clients in this case—or fetch data about a specific resource.
You can either use example codes, which we have used in the recipes from previous chapters, or you can start a new project.
After creating the project, we will need to create a list of clients to serve as an in-memory database. We will need a model class to keep the data that will be shown on the page:
Inside the code.model package, let's create a class named Client with the following code:
package code.model
import net.liftweb.json.JsonDSL._
case class Client(id: Int, name: String, email: String) {
def asJson = {
("id" -> id) ~
("name" -> name) ~
("email" -> email)
}
}Let's create a...
Change the font size
Change margin width
Change background colour