Service API

In order to define our Cook as a service we need to implement a special interface called a service descriptor. The service descriptor defines two aspects of a Lagom service:

  • The service signature: How the service should be called and its return type
  • The service meta data: How the service call is mapped to the transport layer, for example to the REST call

The service descriptor extends Lagom's Service trait and in its simplest form just needs to override the descriptor method. This is what it looks like in our Cook definition, which we place into the cook-api module:

import com.lightbend.lagom.scaladsl.api._import ch15.model._trait CookService extends Service {  def cook: ServiceCall[Dough, RawCookies]  override def descriptor: ...

Get Learn Scala Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.