Created
December 19, 2017 16:36
-
-
Save vijaykarthik/e046b378e4f3a9ac9f4cffa0794dce7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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