/// <summary> /// A Lambda function to respond to HTTP POST methods from API Gateway /// </summary> /// <param name="request"></param> /// <returns>The list of blogs</returns> public async Task <APIGatewayProxyResponse> PostCall(APIGatewayProxyRequest request, ILambdaContext context) { context.Logger.LogLine("POST Request\n"); string result = ""; if (request.Path.Contains("access")) { var data = JsonConvert.DeserializeObject <ClientClass>(request.Body); result = ACCESS_CHECK.Split(',').Count(c => c.ToLower() == data.Client.ToLower()) > 0?"":"No changes allowed"; } else { var data = JsonConvert.DeserializeObject <DataClass>(request.Body); result = ACCESS_CHECK.Split(',').Count(c => c.ToLower() == data.Client.ToLower()) > 0?"":"No changes allowed"; if (string.IsNullOrWhiteSpace(result)) { result = await CsandraGame.SaveGame(data.Data, ACCESS_CLIENT); } } var response = new APIGatewayProxyResponse { StatusCode = (int)(string.IsNullOrWhiteSpace(result)?HttpStatusCode.OK:HttpStatusCode.BadRequest), Body = result, Headers = new Dictionary <string, string> { { "Content-Type", "application/json" }, { "Access-Control-Allow-Origin", "*" } } }; return(response); }
public async Task <APIGatewayProxyResponse> GetCall(APIGatewayProxyRequest request, ILambdaContext context) { var response = new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK, Body = JsonConvert.SerializeObject(await CsandraGame.GetGames(ACCESS_CLIENT)), Headers = new Dictionary <string, string> { { "Content-Type", "application/json" }, { "Access-Control-Allow-Origin", "*" } } }; return(response); }