コード例 #1
0
        public APIGatewayProxyResponse GetTime(APIGatewayProxyRequest request, ILambdaContext context)
        {
            var result = _TimeService.CurrentTimeUTC();

            {
                var statusCode = (result != null) ? (int)HttpStatusCode.OK : (int)HttpStatusCode.InternalServerError;
                var body       = (result != null) ? JsonConvert.SerializeObject(result) : string.Empty;

                var response = new APIGatewayProxyResponse
                {
                    StatusCode = statusCode,
                    Body       = body,
                    Headers    = new Dictionary <string, string>
                    {
                        { "Content-Type", "application/json" },
                        { "Access-Control-Allow-Origin", "*" }
                    }
                };

                return(response);
            }
        }