Book Image

Programming Kotlin

Book Image

Programming Kotlin

Overview of this book

Quickly learn the fundamentals of the Kotlin language and see it in action on the web. Easy to follow and covering the full set of programming features, this book will get you fluent in Kotlin for Android.
Table of Contents (20 chapters)
Programming Kotlin
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface

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", this::useGreeting) 
        ).withAutoAcl(true); 
      } 
    } 

This is quite a simple description of...