micronaut-projects / micronaut-core

Micronaut Application Framework
http://micronaut.io
Apache License 2.0
6.09k stars 1.07k forks source link

Document custom MediaTypes handling #9688

Open sdelamo opened 1 year ago

sdelamo commented 1 year ago

Issue description

We have a custom YAML payload support implemented with the standard Jackson ObjectMapper and Micronaut MediaTypeCodec approach. It's very simple, just two small classes, but worked perfectly with MN 3.x - the codec was properly picked up by DefaultHttpClient from MediaTypeCodecRegistry and YAML payloads were serialized and deserialized as expected. Unfortunately it doesn't work anymore with MN 4. Apparently there was a heavy reimplementation of the http-related logic, including the DefaultHttpClient, which now leverages the newly-introduced MessageBodyHandler API (BTW I'm a bit surprised that such an important logic was replaced by an API which is marked as experimental without an option to switch to the old one). It is mentioned in the documentation only once, in a statement that HttpContentProcessor was superseded by MessageBodyHandler API. Nothing about custom MediaTypes handling, not a word in breaking changes or upgrade guide. Can you please advise how to proceed with this? Should we implement a custom MessageBodyHandler in addition to the two existing classes?

@yawkat

yes you need to implement your own, similar to https://github.com/micronaut-projects/micronaut-core/blob/4.0.x/json-core/src/main/java/io/micronaut/json/body/JsonMessageHandler.java

sdelamo commented 1 year ago

@yawkat could you document this?

sdelamo commented 9 months ago

@yawkat @graemerocher can someone document the MessageBodyHandler API ?