Now that we know how to fetch data, the next step is to learn how to create the data so that we can fetch it later.
Thus, we will learn how to create the REST URL, which will respond to the POST request.
We are going to modify the code we created in the previous recipe. You can duplicate the project from the last recipe to keep it separated or you can use the same one.
Remove the following line from the
boot
method in theBoot
class:ClientCache.startClient()
Then modify the
ClientCache
object by adding a newimport
statement:import net.liftweb.http.SessionVar
Remove the
clients
variable and thestartClient
method, and modify the object declaration fromobject ClientCache
toobject ClientCache extends SessionVar[List[Client]](Nil)
.At last, in the
index.html
file, create a form to input data using this code:<div> <form> <fieldset> <legend>New Client</legend> ...