Rest Controller in Spring Boot for Rock Paper Scissors REST API I have created a Spring Boot Microservice for playing Rock Paper Scissrors. I have tried to follow best practices, but still would appreciate some critique on my code. Thanks.

@RestController
public class RockPaperScissorsController {

  @Autowired
  private PlayerService playerService;

  @Autowired
  private HttpServletRequest context;

  @Autowired
  private GameSessionService gameSessionService;

  @Autowired
  private GameplayService gameplayService;

  public RockPaperScissorsController(PlayerService playerService,
      GameSessionService gameSessionService) {
    this.playerService = playerService;
    this.gameSessionService = gameSessionService;
  }

  @GetMapping(value = "/ping", produces = "application/json")
  public ResponseEntity&lt;String&gt; ping() {
    return ResponseEntity.ok("{\"response\":\"pong\"}");
  }

  @GetMapping(value = "/player/{playerName}", produces = "application/json")
  public ResponseEntity player(@PathVariable("playerName") String playerName) {
    try {
      Player player = playerService.getPlayer(playerName);
      return ResponseEntity.ok(player);
    } catch (RPSException e) {
      return ResponseEntity.badRequest().body(e.getMessage());
    }
  }

  @PostMapping(value = "/player/{playerName}", produces = "application/json")
  public ResponseEntity playerPOST(@PathVariable("playerName") String playerName) {
    try {
      playerService.createPlayer(playerName);
      return ResponseEntity.ok().body("");
    } catch (RPSException e) {
      return ResponseEntity.badRequest().body(e.getMessage());
    }
  }


  @DeleteMapping(value = "/player/{playerName}", produces = "application/json")
  public ResponseEntity playerDELETE(@PathVariable("playerName") String playerName) {
    try {
      playerService.deletePlayer(playerName);
      return ResponseEntity.ok("");
    } catch (RPSException e) {
      return ResponseEntity.badRequest().body(e.getMessage());
    }
  }

  @PostMapping(value = "/createInvite/{playerName}", produces = "application/json")
  public ResponseEntity createInvite(@PathVariable("playerName") String inviter) {
    try {
      Player player = playerService.getPlayer(inviter);
      GameSession session = gameSessionService.createSessionFrom(new Invite(player));
      return ResponseEntity.ok(session);
    } catch (RPSException e) {
      return ResponseEntity.badRequest().body(e.getMessage());
    }
  }

  @PostMapping(value = "/acceptInvite/{inviteCode}/{playerName}", produces = "application/json")
  public ResponseEntity acceptInvite(@PathVariable("inviteCode") String inviteCode,
      @PathVariable("playerName") String playerName) throws InvalidOperationException {
    try {
      Player player = playerService.getPlayer(playerName);
      return ResponseEntity.ok(gameSessionService.acceptInvite(player, inviteCode));
    } catch (RPSException e) {
      return ResponseEntity.badRequest().body(e.getMessage());
    }
  }

  @GetMapping(value = "/session/{inviteCode}", produces = "application/json")
  public ResponseEntity session(@PathVariable("inviteCode") String inviteCode) {
    return ResponseEntity.ok(gameSessionService.sessions().get(inviteCode));
  }

  @PostMapping(value = "/readyplayer/{playername}", produces = "application/json")
  public ResponseEntity ready(@PathVariable("playername") String playerName) {
    try {
      Player player = playerService.changePlayerState(playerName, Player.State.READY);
      return ResponseEntity.ok(player);
    } catch (RPSException e) {
      return ResponseEntity.badRequest().body(e.getMessage());
    }
  }

  @PostMapping(value = "/play", produces = "application/json")
  public ResponseEntity play(@RequestBody PlayRequest playRequest) {
    try {
      gameplayService.play(playRequest);
      return ResponseEntity.ok().body("");
    } catch (RPSException e) {
      e.printStackTrace();
    }
    return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("");
  }

}
You do not need ping within your controller. Check out Spring boot actuator
Each method having duplicated error handling. You can move it to @ControllerAdvice
Method names like playerPOST, playerDELETE aren't helpful. Consider this as a normal class and have normal method names like createPlayer, deletePlayer
You need not define produces attribute for each mapping, RestController defaults to JSON
Returning ok("") doesn't make sense. Should be either returning the player object, or use ResponseEntity.created() (201)
Why are you autowiring HttpServletRequest context?
Should use AllArgsConstructor - constructor based autowiring