Processing a JSON body

When we need to implement other methods, we may need to be able to handle a JSON in the body of the request. A clear example of this is the route to create a customer. As in the example with our RESTful APIs, this should happen when we receive a POST HTTP request on our /customer route.

First, we will need to modify our CustomerHandler class to create a new method that we'll name create:

package com.microservices.chapter4import org.springframework.http.HttpStatusimport org.springframework.stereotype.Componentimport org.springframework.web.reactive.function.BodyInserters.fromObjectimport org.springframework.web.reactive.function.server.ServerRequestimport org.springframework.web.reactive.function.server.ServerResponse.ok ...

Get Hands-On Microservices with 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.