Chapter 9. A reactive interface

 

This chapter covers

  • Headless APIs
  • HTTP, XML, and REST
  • JSON
  • Expressive APIs
  • Play
  • Akka HTTP

Now that you’ve seen how to build a focused microservice containing CQRS command or query functionality, how do you get at it? How does a client use these shiny new reactive applications? Now you need an interface for your service to allow its rubber to meet the road. The service interface (or API) is the way for clients as well as other services to interact with that particular service. In this chapter, we show you how to create a service interface using the most common reactive tools and standards. This chapter also shows you how to add a RESTful interface to your services and shows some basics such as authentication, logging, and bootstrapping.

9.1. What is a reactive interface?

The reactive interface is treated as the outer layer of the service, and the overwhelming go-to interface of choice these days is representational state transfer (REST) over HTTP. REST is a lightweight interface, typically using JavaScript Object Notation (JSON) as the payload of choice. Extensible Markup Language (XML) is sometimes used as well, but it’s considered to be more verbose. This chapter focuses on servicing RESTful clients such as UIs and doesn’t cover streaming as an interface. But streaming is becoming more common as a way to connect services and systems, and the subject can easily fill an entire book.

9.2. Expressive RESTful interfaces

9.3. Choosing your reactive API library

9.4. Akka HTTP: a simple CQRS-esque service

9.5. Lagom: the order example

9.6. Play vs Akka HTTP vs Lagom

Summary