Defining services

When writing your project, you should adhere to best practices and standards. A service interface should always be placed in a *-api project. You can see the HelloService interface follows the same rule. The requirement is for your service interface to extend the Lagom service interface and provide a default implementation for the descriptor method. The descriptor is responsible for mapping the service to the underlying transport protocol.

 public interface HelloService extends Service { ServiceCall<NotUsed, String> hello(String id); ServiceCall<GreetingMessage, Done> useGreeting(String id); @Override default Descriptor descriptor() { return named("hello").withCalls( pathCall("/api/hello/:id", this::hello), pathCall("/api/hello/:id", ...

Get Programming Kotlin 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.