Completed first revision of front end. Enabled CORS in spring. Allowed path variable to be optional.
This commit is contained in:
parent
c160703048
commit
e5a84268cc
11 changed files with 456 additions and 328 deletions
|
@ -3,6 +3,9 @@ package achievements;
|
|||
import achievements.services.DbConnectionService;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
@ -16,4 +19,16 @@ public class Application {
|
|||
SpringApplication.exit(context, () -> 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer configurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry
|
||||
.addMapping("/*")
|
||||
.allowedOrigins("*");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ public class Controller {
|
|||
|
||||
public Controller() {}
|
||||
|
||||
@RequestMapping(value = "/achievements/{Name}", method = GET, produces = "application/json")
|
||||
public ResponseEntity<String> fetchAchievements(@PathVariable("Name") String getName) {
|
||||
@RequestMapping(value = { "/achievements", "/achievements/{Name}" }, method = GET, produces = "application/json")
|
||||
public ResponseEntity<String> fetchAchievements(@PathVariable(value = "Name", required = false) String getName) {
|
||||
var achievements = (Achievements) null;
|
||||
if (getName == null) {
|
||||
achievements = db.getAchievements("%");
|
||||
|
@ -42,8 +42,8 @@ public class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/games/{Name}", method = GET, produces = "text/html")
|
||||
public ResponseEntity<String> fetchGames(@PathVariable("Name") String getName) {
|
||||
@RequestMapping(value = { "/games", "/games/{Name}" }, method = GET, produces = "application/json")
|
||||
public ResponseEntity<String> fetchGames(@PathVariable(value = "Name", required = false) String getName) {
|
||||
var games = (Games) null;
|
||||
if (getName == null) {
|
||||
games = db.getGames("%");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue