Hi all,
I am using Scala with Lagom and want to make one of the input parameter as optional in the path of the rest Call method. Suppose the service descriptor is as below:
trait CounterService extends Service {
def getCountsOfRecords(Id: String, count: Int):
ServiceCall[NotUsed, JsValue]
override final def descriptor = {
import Service._
named("Counts")
.withCalls(
restCall(GET,
"/userId/:id/topcounts/:count", getCountsOfRecords _),
restCall(GET,
"/userId/:id/topcounts", getCountsOfRecords _),
)
.withAutoAcl(true)
}
}
Here, I want to use the the same handler for two different purposes,
- Show top 10 records by default
- Show top of records
For example:
- /userId/12/topcounts - Should return default top 10 records
- /userId/12/topcounts/20 - Should return top 20 records
Could you please suggest me the way I should do it?
Thanks in advance.