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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.