org.springframework.web.reactive.config.CorsRegistry Java Examples

The following examples show how to use org.springframework.web.reactive.config.CorsRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobalCorsConfigIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void addCorsMappings(CorsRegistry registry) {
	registry.addMapping("/cors-restricted")
			.allowedOrigins("https://foo")
			.allowedMethods("GET", "POST");
	registry.addMapping("/cors");
	registry.addMapping("/ambiguous")
			.allowedMethods("GET", "POST");
}
 
Example #2
Source File: DefaultControllerSpecTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void configurerConsumers() {
	TestConsumer<ArgumentResolverConfigurer> argumentResolverConsumer = new TestConsumer<>();
	TestConsumer<RequestedContentTypeResolverBuilder> contenTypeResolverConsumer = new TestConsumer<>();
	TestConsumer<CorsRegistry> corsRegistryConsumer = new TestConsumer<>();
	TestConsumer<FormatterRegistry> formatterConsumer = new TestConsumer<>();
	TestConsumer<ServerCodecConfigurer> codecsConsumer = new TestConsumer<>();
	TestConsumer<PathMatchConfigurer> pathMatchingConsumer = new TestConsumer<>();
	TestConsumer<ViewResolverRegistry> viewResolverConsumer = new TestConsumer<>();

	new DefaultControllerSpec(new MyController())
			.argumentResolvers(argumentResolverConsumer)
			.contentTypeResolver(contenTypeResolverConsumer)
			.corsMappings(corsRegistryConsumer)
			.formatters(formatterConsumer)
			.httpMessageCodecs(codecsConsumer)
			.pathMatching(pathMatchingConsumer)
			.viewResolvers(viewResolverConsumer)
			.build();

	assertNotNull(argumentResolverConsumer.getValue());
	assertNotNull(contenTypeResolverConsumer.getValue());
	assertNotNull(corsRegistryConsumer.getValue());
	assertNotNull(formatterConsumer.getValue());
	assertNotNull(codecsConsumer.getValue());
	assertNotNull(pathMatchingConsumer.getValue());
	assertNotNull(viewResolverConsumer.getValue());

}
 
Example #3
Source File: GlobalCorsConfigIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void addCorsMappings(CorsRegistry registry) {
	registry.addMapping("/cors-restricted")
			.allowedOrigins("http://foo")
			.allowedMethods("GET", "POST");
	registry.addMapping("/cors");
	registry.addMapping("/ambiguous")
			.allowedMethods("GET", "POST");
}
 
Example #4
Source File: DefaultControllerSpecTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void configurerConsumers() {
	TestConsumer<ArgumentResolverConfigurer> argumentResolverConsumer = new TestConsumer<>();
	TestConsumer<RequestedContentTypeResolverBuilder> contenTypeResolverConsumer = new TestConsumer<>();
	TestConsumer<CorsRegistry> corsRegistryConsumer = new TestConsumer<>();
	TestConsumer<FormatterRegistry> formatterConsumer = new TestConsumer<>();
	TestConsumer<ServerCodecConfigurer> codecsConsumer = new TestConsumer<>();
	TestConsumer<PathMatchConfigurer> pathMatchingConsumer = new TestConsumer<>();
	TestConsumer<ViewResolverRegistry> viewResolverConsumer = new TestConsumer<>();

	new DefaultControllerSpec(new MyController())
			.argumentResolvers(argumentResolverConsumer)
			.contentTypeResolver(contenTypeResolverConsumer)
			.corsMappings(corsRegistryConsumer)
			.formatters(formatterConsumer)
			.httpMessageCodecs(codecsConsumer)
			.pathMatching(pathMatchingConsumer)
			.viewResolvers(viewResolverConsumer)
			.build();

	assertNotNull(argumentResolverConsumer.getValue());
	assertNotNull(contenTypeResolverConsumer.getValue());
	assertNotNull(corsRegistryConsumer.getValue());
	assertNotNull(formatterConsumer.getValue());
	assertNotNull(codecsConsumer.getValue());
	assertNotNull(pathMatchingConsumer.getValue());
	assertNotNull(viewResolverConsumer.getValue());

}
 
Example #5
Source File: FrontendApplication.java    From spring-5-examples with MIT License 5 votes vote down vote up
@Override
public void addCorsMappings(final CorsRegistry registry) {
  registry.addMapping("/api/**")
          .allowedOrigins("*")
          .allowedMethods("POST", "PUT", "DELETE")
          .allowCredentials(true)
          .maxAge(3600);
}
 
Example #6
Source File: CorsWebFluxConfigurer.java    From streaming-file-server with MIT License 5 votes vote down vote up
@Override
public void addCorsMappings(CorsRegistry corsRegistry) {
  corsRegistry.addMapping("/**")
              .allowedHeaders("x-requested-with", "authorization", "Content-Type",
                              "Authorization", "credential", "X-XSRF-TOKEN")
              .allowedMethods("GET", "PUT", "POST", "DELETE", "OPTIONS")
              .allowedOrigins("*")
              .maxAge(3600);
}
 
Example #7
Source File: CorsGlobalConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void addCorsMappings(CorsRegistry corsRegistry) {
    corsRegistry.addMapping("/**")
        .allowedOrigins("http://allowed-origin.com")
        .allowedMethods("PUT")
        .allowedHeaders("Baeldung-Allowed", "Baledung-Another-Allowed")
        .exposedHeaders("Baeldung-Allowed", "Baeldung-Exposed")
        .maxAge(3600);
}
 
Example #8
Source File: DefaultControllerSpec.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public DefaultControllerSpec corsMappings(Consumer<CorsRegistry> consumer) {
	this.configurer.corsRegistryConsumer = consumer;
	return this;
}
 
Example #9
Source File: DefaultControllerSpec.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public void addCorsMappings(CorsRegistry registry) {
	if (this.corsRegistryConsumer != null) {
		this.corsRegistryConsumer.accept(registry);
	}
}
 
Example #10
Source File: DefaultControllerSpec.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public DefaultControllerSpec corsMappings(Consumer<CorsRegistry> consumer) {
	this.configurer.corsRegistryConsumer = consumer;
	return this;
}
 
Example #11
Source File: DefaultControllerSpec.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public void addCorsMappings(CorsRegistry registry) {
	if (this.corsRegistryConsumer != null) {
		this.corsRegistryConsumer.accept(registry);
	}
}
 
Example #12
Source File: CORSFilter.java    From spring-boot-webflux-jjwt with Apache License 2.0 4 votes vote down vote up
@Override
public void addCorsMappings(CorsRegistry registry) {
	registry.addMapping("/**").allowedOrigins("*").allowedMethods("*").allowedHeaders("*");
}
 
Example #13
Source File: Application.java    From spring-reactive-playground with Apache License 2.0 4 votes vote down vote up
@Override
public void addCorsMappings(CorsRegistry registry) {
	registry.addMapping("/cors/config");
}
 
Example #14
Source File: WebTestClient.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Configure CORS support.
 * @see WebFluxConfigurer#addCorsMappings
 */
ControllerSpec corsMappings(Consumer<CorsRegistry> consumer);
 
Example #15
Source File: WebTestClient.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Configure CORS support.
 * @see WebFluxConfigurer#addCorsMappings
 */
ControllerSpec corsMappings(Consumer<CorsRegistry> consumer);