@Override
	public void handle(HttpExchange exchange) throws IOException {
		System.out.println("In list games handler");
		
		String responseMessage = "";
		
		if(exchange.getRequestMethod().toLowerCase().equals("get")) {
			String unvalidatedCookie = exchange.getRequestHeaders().get("Cookie").get(0);
			System.out.println(unvalidatedCookie);
			try {  // check user login cookie and if valid get params
				
				Cookie.verifyCookie(unvalidatedCookie, translator);
				System.out.println("good cookie");
				List<String> gameAI = this.gameFacade.listAI();
				responseMessage = this.translator.translateTo(gameAI.toArray());			
				exchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, 0);
				
			} catch (InvalidCookieException e) { // else send error message
				System.out.println("bad cookie");
				responseMessage = "Error: You either did not provide a cookie or the provided cookie is invalid";
				exchange.sendResponseHeaders(HttpURLConnection.HTTP_BAD_REQUEST, 0);
			}
		}
		else {
			// unsupported request method
			responseMessage = "Error: \"" + exchange.getRequestMethod() + "\" is no supported!";
			exchange.sendResponseHeaders(HttpURLConnection.HTTP_BAD_REQUEST, 0);
		}
		
		//set "Content-Type: application/json" header
		List<String> contentTypes = new ArrayList<String>();
		String appJson = "application/json";
		contentTypes.add(appJson);
		exchange.getResponseHeaders().put("Content-type", contentTypes);
		
		//send failure response message
		OutputStreamWriter writer = new OutputStreamWriter(
				exchange.getResponseBody());
		writer.write(responseMessage);
		writer.flush();
		writer.close();
		
		exchange.getResponseBody().close();
	}