communication with the frontend works
This commit is contained in:
parent
f5a5ba6387
commit
a7b76976ac
1 changed files with 28 additions and 0 deletions
28
src/main/java/de/telekom/silly_game/GameController.java
Normal file
28
src/main/java/de/telekom/silly_game/GameController.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package de.telekom.silly_game;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin(origins = "http://localhost:4200")
|
||||||
|
@RequestMapping("/game")
|
||||||
|
public class GameController {
|
||||||
|
|
||||||
|
@GetMapping("/start")
|
||||||
|
public String startGame() {
|
||||||
|
return "Game started!";
|
||||||
|
}
|
||||||
|
|
||||||
|
private AtomicInteger jumpCount = new AtomicInteger(0);
|
||||||
|
|
||||||
|
@GetMapping("/jump")
|
||||||
|
public Map<String, Integer> registerJump() {
|
||||||
|
int total = jumpCount.incrementAndGet();
|
||||||
|
total = total/2;
|
||||||
|
System.out.println(total);
|
||||||
|
return Collections.singletonMap("totalJumps", total);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue