Open raunak2007 opened 8 months ago
this is the code more related to accessing the cookie as mort requested:
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@PostMapping("/getCash")
public ResponseEntity<Object> getCash(HttpServletRequest request) {
Cookie[] cookies = request.getCookies();
String email = null;
if (cookies != null) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("email")) {
email = cookie.getValue();
break;
}
}
}
if (email == null) {
return new ResponseEntity<>("Cookie 'email' not found", HttpStatus.BAD_REQUEST);
}
Person player = personDetailsService.getByEmail(email);
if (player == null) {
return new ResponseEntity<>("Person not found", HttpStatus.NOT_FOUND);
}
int cash = player.getCash();
return new ResponseEntity<>(cash, HttpStatus.OK);
}
if statements are an example of a control structure
Agile Manifesto:
Our Progress
Work Each Person Did
Sreeja
Vinay
Raunak
Pull Requests For Integrating NBA and Corn Farmer Game!: https://github.com/Del-Norte-Farmers-Iowa-Hawkeyes-Fanclub/The-Del-Norte-Association-of-Farmers-Presents-Interactive-Sustainable-Farming-Initiative/pull/13