[JAVA-26374-boot-runtime] Moved "CORS with Spring" article to spring-boot-runtime (#15096)

This commit is contained in:
panos-kakos
2023-11-06 09:45:12 +00:00
committed by GitHub
parent 91293d64b0
commit 81be7c4ad5
5 changed files with 1 additions and 1 deletions
@@ -4,5 +4,4 @@ This module contains articles about administering a Spring Boot runtime
### Relevant Articles:
- [Configure the Heap Size When Starting a Spring Boot Application](https://www.baeldung.com/spring-boot-heap-size)
- [CORS with Spring](https://www.baeldung.com/spring-cors)
- [Max-HTTP-Header-Size in Spring Boot 2](https://www.baeldung.com/spring-boot-max-http-header-size)
@@ -1,18 +0,0 @@
package com.baeldung.cors;
public class Account {
private Long id;
public Account(Long id) {
this.id = id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
@@ -1,24 +0,0 @@
package com.baeldung.cors;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin(maxAge = 3600)
@RestController
@RequestMapping("/account")
public class AccountController {
@CrossOrigin("http://example.com")
@RequestMapping(method = RequestMethod.GET, path = "/{id}")
public Account retrieve(@PathVariable Long id) {
return new Account(id);
}
@RequestMapping(method = RequestMethod.DELETE, path = "/{id}")
public void remove(@PathVariable Long id) {
// ...
}
}
@@ -1,16 +0,0 @@
package com.baeldung.cors.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**");
}
}