Hi, just making a start with Arrow & enjoying ...
# arrow
a
Hi, just making a start with Arrow & enjoying it. I'm trying to use it to add a functional layer to a Spring MVC application so that returns from services are wrapped in Try to capture exceptions & then the Controller can return Either a Success or Failure response.
Copy code
fun getCustomer(@PathVariable customerId: String): ResponseEntity<Either<ErrorResponse, CustomerResponse>> {
        val result = Try { getCustomerService.getCustomer(customerId) }
        return result.fold({ err -> ResponseEntity(Either.Left(ErrorResponse()), HttpStatus.INTERNAL_SERVER_ERROR) },
                { customer -> ResponseEntity(Either.Right(CustomerResponse(customer)), HttpStatus.OK) }
        )
    }
This looks ok but obviously the JSON in the response has the full contents of Either.Right e.g.
{"b":{"customer": ... },"right$arrow_core":true,"left$arrow_core":false,"left":false,"right":true}
Is there an easy way to override the
MappingJackson2HttpMessageConverter
so that it contains the value in the Right/Left rather than the full object?