If I send empty body.
In the following codejson will be empty mono, flatMap won't be invoked at all, therefore validation and handler won't be invoked too. Endpoint returns empty body with 200 http status code.
fun validate(handler: (T) -> Mono<ServerResponse>): Mono<ServerResponse> {
val success = { json: String -> objectMapperFactory().readValue(json, bodyType) }
val json = request.body(BodyExtractors.toMono(String::class.java))
return json.flatMap { validator.validate(request, it) ?: handler(success(it)) }
}
If I send empty body. In the following code
json
will be empty mono,flatMap
won't be invoked at all, therefore validation and handler won't be invoked too. Endpoint returns empty body with 200 http status code.