Skip to content

Instantly share code, notes, and snippets.

@vijaykarthik
Created December 19, 2017 16:36
Show Gist options
  • Save vijaykarthik/e046b378e4f3a9ac9f4cffa0794dce7d to your computer and use it in GitHub Desktop.
Save vijaykarthik/e046b378e4f3a9ac9f4cffa0794dce7d to your computer and use it in GitHub Desktop.
public class ApiDecoratorApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(applicationClass, args);
}
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
/*
* ((SimpleClientHttpRequestFactory) restTemplate.getRequestFactory())
* .setReadTimeout(readTimeout); ((SimpleClientHttpRequestFactory)
* restTemplate.getRequestFactory()) .setConnectTimeout(connectTimeout);
*/
return restTemplate;
}
@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
/*
* this is to enable JSONP response. If callback is passed in URL - respond
* with JSONP Support enabled in Spring 4.1!!
*/
@ControllerAdvice
static class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
public JsonpAdvice() {
super("callback");
}
}
private static Class<ApiDecoratorApplication> applicationClass = ApiDecoratorApplication.class;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment