I am trying to implement the BodyExtractor interface get the body from Mono< ClientResponse> as an Object instead of it in Mono.
I could not find any example of BodyExtractor implementation. I am wondering is this a good idea to implement it or is there any other way to get the body as an object.
Below is the code line that I currently have
public Mono<ResponseEntity<Mono<JsonNode>>> processUnmappedApiRequest(ServerHttpRequest request, JsonNode body) { RequestData reqData = this.prepareReqMetadata(request, body); Mono<ClientResponse> response = commonConnector.getApiResponse(reqData); return response.map(respData -> { int latestVersion = respData.headers().header("version").size() == 0 ? getLatestVersion(request) : Integer.parseInt(respData.headers().header("version").get(0)); List converterList; if((converterList = converterSequenceProvider.getConverterList(reqData.getRequestPath(), latestVersion, reqData.getVersion())) != null){ return ResponseEntity.ok().body(respData.bodyToMono(JsonNode.class).map(respBody -> convertToDesiredVersion(converterList, respBody))); } return ResponseEntity.ok().body(respData.bodyToMono(JsonNode.class)); }); }
In this method my return type is Mono< ResponseEntity< Mono< JsonNode>>> and I am trying to convert it to Mono< ResponseEntity< JsonNode>> because my team is not agreeing with Mono inside a Mono.
So the main point here is I don't want to use bodyToMono method and I am not sure how to use body method.
Please help me out here.