I'm trying to add msgpack binary dataformat as a content negotiation option. The Json and Xml works fine out of the box. I tried to add jackson msgpack mapper as a bean, like in this examle, but it does not work. When I add Accept: application/x-msgpack
header to my request 406 Not Acceptable
code is returned.
Here's my WebConfig:
@Configuration
@EnableWebMvc
@SuppressWarnings("unused")
public class WebConfig extends WebMvcConfigurerAdapter {
@Bean
public HttpMessageConverter messagePackMessageConverter() {
return new AbstractJackson2HttpMessageConverter(
new ObjectMapper(new MessagePackFactory()),
new MediaType("application", "x-msgpack")) {
};
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false)
.ignoreAcceptHeader(false)
.favorParameter(true)
.defaultContentType(MediaType.APPLICATION_JSON)
.mediaType("xml", MediaType.APPLICATION_XML)
.mediaType("msgpack", new MediaType("application", "x-msgpack"));
}
}
I didn't add any special annotations to my DTO objects, and my controller is nothing out of the ordinary either.
My msgpack dependency is:
org.msgpack:jackson-dataformat-msgpack:0.7.0-p3