http service: use gson instead of jackson for json serialization

This fixes deserailization of the loot timestamps for the loot tracker,
and maybe other things. Note this does not use the same Gson instance as
http-api as Spring creates its own Gson, however they are both default
Gson instances.
This commit is contained in:
Adam
2019-02-16 21:14:17 -05:00
parent ca8ee682fa
commit fe2eba06a7
2 changed files with 18 additions and 6 deletions

View File

@@ -24,22 +24,35 @@
*/
package net.runelite.http.service;
import java.util.List;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
/**
* Configure .js as application/json to trick Cloudflare into caching json responses
*/
@Configuration
@EnableWebMvc
public class SpringContentNegotiationConfigurer extends WebMvcConfigurerAdapter
public class SpringWebMvcConfigurer extends WebMvcConfigurerAdapter
{
/**
* Configure .js as application/json to trick Cloudflare into caching json responses
*/
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer)
{
configurer.mediaType("js", MediaType.APPLICATION_JSON);
}
/**
* Use GSON instead of Jackson for JSON serialization
* @param converters
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters)
{
converters.add(new GsonHttpMessageConverter());
}
}

View File

@@ -7,5 +7,4 @@ minio.bucket=runelite
runelite.twitter.consumerkey=moo
runelite.twitter.secretkey=cow
runelite.twitter.listid=968949795153948673
logging.level.net.runelite=DEBUG
spring.jackson.serialization.indent_output=true
logging.level.net.runelite=DEBUG