Remapping the APIs call

This commit is contained in:
francesco 2020-03-09 13:31:21 +01:00
parent 126f441b07
commit ab934d8804
10 changed files with 30 additions and 8 deletions

View File

@ -27,10 +27,10 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -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");
}
}

View File

@ -3,13 +3,16 @@ package org.gcube.app.springbootangulardemo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping("/api")
//@ResponseBody
public class GreetingController {
//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,
final Model model) {

View File

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api")
public class GreetingRestController {
String template = "Hello, %s!";

View File

@ -1 +1,2 @@
# application.properties
spring.profiles.active=development

View File

@ -1,5 +1,5 @@
#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
groupId=org.gcube.app
m2e.projectName=springboot-angular-app-demo-0.0.1-SNAPSHOT

View File

@ -27,10 +27,10 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -1 +1,2 @@
# application.properties
spring.profiles.active=development