Refine search
@CrossOrigin(origins = "http://localhost:9000") @GetMapping("/greeting") public Greeting greeting(@RequestParam(required=false, defaultValue="World") String name) { System.out.println("==== in greeting ===="); return new Greeting(counter.incrementAndGet(), String.format(template, name)); }
@CrossOrigin("${myOrigin}") @RequestMapping("/someOrigin") public void customOriginDefinedViaPlaceholder() { } }
return; for (String origin : annotation.origins()) { config.addAllowedOrigin(resolveCorsAnnotationValue(origin)); for (RequestMethod method : annotation.methods()) { config.addAllowedMethod(method.name()); for (String header : annotation.allowedHeaders()) { config.addAllowedHeader(resolveCorsAnnotationValue(header)); for (String header : annotation.exposedHeaders()) { config.addExposedHeader(resolveCorsAnnotationValue(header)); String allowCredentials = resolveCorsAnnotationValue(annotation.allowCredentials()); if ("true".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(true); if (annotation.maxAge() >= 0 && config.getMaxAge() == null) { config.setMaxAge(annotation.maxAge());
/** * Spring Data repository interface to manage {@link Customer} instances. * * @author Oliver Gierke * @author Mark Paluch * @soundtrack The Intersphere - Out of phase (Live at Alte Feuerwache Mannheim) */ @CrossOrigin(origins = { "http://localhost", "http://localhost:1234" }) public interface CustomerRepository extends CrudRepository<Customer, Long> {}
return; for (String origin : annotation.origins()) { config.addAllowedOrigin(resolveCorsAnnotationValue(origin)); config.addAllowedMethod(method.name()); for (String header : annotation.allowedHeaders()) { config.addAllowedHeader(resolveCorsAnnotationValue(header)); for (String header : annotation.exposedHeaders()) { config.addExposedHeader(resolveCorsAnnotationValue(header)); String allowCredentials = resolveCorsAnnotationValue(annotation.allowCredentials()); if ("true".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(true);
@CrossOrigin @GetMapping("/default") public String defaultAnnotation() { return "default"; }
@CrossOrigin( origins = { "http://site1.com", "http://site2.com" }, allowedHeaders = { "header1", "header2" }, exposedHeaders = { "header3", "header4" }, methods = RequestMethod.GET, maxAge = 123, allowCredentials = "false") @RequestMapping(path = "/customized", method = { RequestMethod.GET, RequestMethod.POST }) public String customized() { return "customized"; }
@CrossOrigin("http://site1.com") @GetMapping("/origin-value-attribute") public String customOriginDefinedViaValueAttribute() { return "value-attribute"; }
return; for (String origin : annotation.origins()) { config.addAllowedOrigin(resolveCorsAnnotationValue(origin)); for (RequestMethod method : annotation.methods()) { config.addAllowedMethod(method.name()); for (String header : annotation.allowedHeaders()) { config.addAllowedHeader(resolveCorsAnnotationValue(header)); for (String header : annotation.exposedHeaders()) { config.addExposedHeader(resolveCorsAnnotationValue(header)); String allowCredentials = resolveCorsAnnotationValue(annotation.allowCredentials()); if ("true".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(true); if (annotation.maxAge() >= 0 && config.getMaxAge() == null) { config.setMaxAge(annotation.maxAge());
@CrossOrigin(origins = { "http://site1.com", "http://site2.com" }, allowedHeaders = { "header1", "header2" }, exposedHeaders = { "header3", "header4" }, methods = RequestMethod.DELETE, maxAge = 123, allowCredentials = "false") @RequestMapping(path = "/customized", method = { RequestMethod.GET, RequestMethod.POST }) public void customized() { }
@CrossOrigin("${myOrigin}") @GetMapping("/origin-placeholder") public String customOriginDefinedViaPlaceholder() { return "placeholder"; } }
return; for (String origin : annotation.origins()) { config.addAllowedOrigin(resolveCorsAnnotationValue(origin)); for (RequestMethod method : annotation.methods()) { config.addAllowedMethod(method.name()); for (String header : annotation.allowedHeaders()) { config.addAllowedHeader(resolveCorsAnnotationValue(header)); for (String header : annotation.exposedHeaders()) { config.addExposedHeader(resolveCorsAnnotationValue(header)); String allowCredentials = resolveCorsAnnotationValue(annotation.allowCredentials()); if ("true".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(true); if (annotation.maxAge() >= 0 && config.getMaxAge() == null) { config.setMaxAge(annotation.maxAge());
@CrossOrigin(allowCredentials = "bogus") @RequestMapping("/bogus") public void bogusAllowCredentialsValue() { } }
@CrossOrigin @GetMapping(path = "/ambiguous-produces", produces = "application/json") public String ambiguousProducesJson() { return "{}"; }
private void updateCorsConfig(CorsConfiguration config, CrossOrigin annotation) { for (String origin : annotation.origins()) { config.addAllowedOrigin(resolveCorsAnnotationValue(origin)); } for (RequestMethod method : annotation.methods()) { config.addAllowedMethod(method.name()); } for (String header : annotation.allowedHeaders()) { config.addAllowedHeader(resolveCorsAnnotationValue(header)); } for (String header : annotation.exposedHeaders()) { config.addExposedHeader(resolveCorsAnnotationValue(header)); } String allowCredentials = resolveCorsAnnotationValue(annotation.allowCredentials()); if ("true".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(true); } else if ("false".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(false); } else if (!allowCredentials.isEmpty()) { throw new IllegalStateException("@CrossOrigin's allowCredentials value must be \"true\", \"false\", " + "or an empty string (\"\"): current value is [" + allowCredentials + "]"); } if (annotation.maxAge() >= 0 && config.getMaxAge() == null) { config.setMaxAge(annotation.maxAge()); } }
@CrossOrigin("http://example.com") @RequestMapping("/customOrigin") public void customOriginDefinedViaValueAttribute() { }
@CrossOrigin @GetMapping(path = "/ambiguous-produces", produces = "application/xml") public String ambiguousProducesXml() { return "<a></a>"; }
private void updateCorsConfig(CorsConfiguration config, CrossOrigin annotation) { for (String origin : annotation.origins()) { config.addAllowedOrigin(resolveCorsAnnotationValue(origin)); } for (RequestMethod method : annotation.methods()) { config.addAllowedMethod(method.name()); } for (String header : annotation.allowedHeaders()) { config.addAllowedHeader(resolveCorsAnnotationValue(header)); } for (String header : annotation.exposedHeaders()) { config.addExposedHeader(resolveCorsAnnotationValue(header)); } String allowCredentials = resolveCorsAnnotationValue(annotation.allowCredentials()); if ("true".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(true); } else if ("false".equalsIgnoreCase(allowCredentials)) { config.setAllowCredentials(false); } else if (!allowCredentials.isEmpty()) { throw new IllegalStateException("@CrossOrigin's allowCredentials value must be \"true\", \"false\", " + "or an empty string (\"\"): current value is [" + allowCredentials + "]"); } if (annotation.maxAge() >= 0 && config.getMaxAge() == null) { config.setMaxAge(annotation.maxAge()); } }
@CrossOrigin(allowCredentials = "true") @RequestMapping(path = "/baz", method = RequestMethod.GET) public void baz() { }
@CrossOrigin @GetMapping(path = "/ambiguous-produces", produces = "application/json") public String ambiguousProducesJson() { return "{}"; }