Skip to content

Commit

Permalink
fix(web-config): force spring to always return json (#3846)
Browse files Browse the repository at this point in the history
By default, most browsers will not specify `application/json` in the accept header, but will specify `application/xml`
clouddriver will gladly oblige and return `xml`. XML is so 2001... force responses to be `json`
  • Loading branch information
marchello2000 committed Jul 3, 2019
1 parent 1664d25 commit 4e1e1c2
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.core.Ordered
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.filter.ShallowEtagHeaderFilter
Expand Down Expand Up @@ -72,7 +73,7 @@ public class WebConfig extends WebMvcConfigurerAdapter {
RequestQueue requestQueue(DynamicConfigService dynamicConfigService,
RequestQueueConfiguration requestQueueConfiguration,
Registry registry) {
return RequestQueue.forConfig(dynamicConfigService, registry, requestQueueConfiguration);
return RequestQueue.forConfig(dynamicConfigService, registry, requestQueueConfiguration)
}

@Bean
Expand All @@ -84,8 +85,10 @@ public class WebConfig extends WebMvcConfigurerAdapter {

@Override
void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
super.configureContentNegotiation(configurer)
configurer.favorPathExtension(false)
configurer
.defaultContentType(MediaType.APPLICATION_JSON_UTF8)
.favorPathExtension(false)
.ignoreAcceptHeader(true)
}

@ControllerAdvice
Expand Down

0 comments on commit 4e1e1c2

Please sign in to comment.