public async Task <APIGatewayProxyResponse> RunHandler(APIGatewayProxyRequest request, ILambdaContext context) { await this.Initialize(request, context); // Run query HandlerResponse response = await this.CommandHandler(); // Response to client APIGatewayProxyResponse httpResponse = await this.CreateGatewayResponse(response); return(httpResponse); }
public async Task <APIGatewayProxyResponse> RunHandler(APIGatewayProxyRequest request, ILambdaContext context) { await this.Initialize(request, context); // Run query TRequestBodyData requestBody = await base.DeserializeResponseBody <TRequestBodyData>(base.ProxyRequest.Body); HandlerResponse response = await this.CommandHandler(requestBody); // Response to client APIGatewayProxyResponse httpResponse = await this.CreateGatewayResponse(response); return(httpResponse); }
protected virtual async Task <APIGatewayProxyResponse> CreateGatewayResponse(HandlerResponse response) { if (!response.Headers.ContainsKey("Content-Type")) { response.Headers["Content-Type"] = this.GetDefaultContentType(); } var httpResponse = new APIGatewayProxyResponse { Headers = response.Headers, StatusCode = response.HttpStatusCode }; if (response.Data != null) { httpResponse.Body = await this.SerializeResponseBody(response.Data); } return(httpResponse); }
public static HandlerResponse StatusOk <TData>(this ApiGatewayHandler handler, TData data) { var response = new HandlerResponse(data, (int)HttpStatusCode.OK); return(response); }