-
-
Save manuelernesto/4c5135f254c1ba4fc56c6f1f54351d68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping("api/v1/players") | |
@RestController | |
class PlayerController(val service: PlayerService) { | |
@GetMapping | |
fun getAllPlayers() = service.getAll() | |
@GetMapping("/{id}") | |
fun getPlayer(@PathVariable id: Long) = service.getById(id) | |
@PostMapping | |
@ResponseStatus(HttpStatus.CREATED) | |
fun savePlayer(@RequestBody player: Player): Player = service.create(player) | |
@DeleteMapping("/{id}") | |
@ResponseStatus(HttpStatus.NO_CONTENT) | |
fun deletePlayer(@PathVariable id: Long) = service.remove(id) | |
@PutMapping("/{id}") | |
fun updatePlayer( | |
@PathVariable id: Long, @RequestBody player: Player | |
) = service.update(id, player) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment