Can someone explain the basic concept and why is it used? and how is it useful?
entity is of type HttpEntity . From the code comments :
Models an object (aka body or content) of an HTTP message.
This is an abstraction over the contents of an HTTP request. Many times when you send an HTTP request, they provide a payload inside the request body. This body can be in many formats, JSON and XML are popular.
When you write:
entity(as[Student])
You are trying to destroy or reject the request body into the data structure to your liking. This means that your obj field in the continuation function will be of type Student .
source share