Remapping the APIs call
This commit is contained in:
parent
126f441b07
commit
ab934d8804
4
pom.xml
4
pom.xml
|
@ -27,10 +27,10 @@
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency> -->
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.gcube.app.springbootangulardemo.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Profile("development")
|
||||||
|
public class DevCorsConfiguration implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/api/**").allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS");
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,13 +3,16 @@ package org.gcube.app.springbootangulardemo.controller;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@RequestMapping("/api")
|
||||||
|
//@ResponseBody
|
||||||
public class GreetingController {
|
public class GreetingController {
|
||||||
|
|
||||||
//This return the templates/greeting.html
|
//This return the templates/greeting.html
|
||||||
@RequestMapping("/greeting")
|
@RequestMapping(value = "/greeting", method = RequestMethod.GET, produces = {"text/html"})
|
||||||
public String greeting(@RequestParam(name="name", required=false, defaultValue="World") final String name,
|
public String greeting(@RequestParam(name="name", required=false, defaultValue="World") final String name,
|
||||||
final Model model) {
|
final Model model) {
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping("/api")
|
||||||
public class GreetingRestController {
|
public class GreetingRestController {
|
||||||
|
|
||||||
String template = "Hello, %s!";
|
String template = "Hello, %s!";
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
# application.properties
|
||||||
|
spring.profiles.active=development
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#Generated by Maven Integration for Eclipse
|
#Generated by Maven Integration for Eclipse
|
||||||
#Fri Mar 06 15:27:28 CET 2020
|
#Mon Mar 09 13:17:17 CET 2020
|
||||||
version=0.0.1-SNAPSHOT
|
version=0.0.1-SNAPSHOT
|
||||||
groupId=org.gcube.app
|
groupId=org.gcube.app
|
||||||
m2e.projectName=springboot-angular-app-demo-0.0.1-SNAPSHOT
|
m2e.projectName=springboot-angular-app-demo-0.0.1-SNAPSHOT
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency> -->
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
# application.properties
|
||||||
|
spring.profiles.active=development
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue