我正在尝试创建一个连接到 lambda 的 API 网关,它使用 handlebars 解析 HTML 模板,然后返回它,但是当我在本地运行它时,甚至在使用 AWS 的测试 url 上运行时,我都收到了这个错误。
{
"errorMessage": "invalid character 'e' looking for beginning of value",
"errorType": "SyntaxError"
}
这是我的 SAM 模板
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: data-template-renderer
Parameters:
Stage:
Type: String
AllowedValues:
- dev
- staging
- production
Description: environment values
Resources:
# Defining the API Resource here means we can define the stage name rather than
# always being forced to have staging/prod. Also means we can add a custom domain with
# to the API gateway within this template if needed. Unfortunately there is a side effect
# where it creates a stage named "Stage". This is a known bug and the issue can be
# found at https://github.com/awslabs/serverless-application-model/issues/191
DataTemplateRendererApi:
Type: AWS::Serverless::Api
Properties:
Name: !Sub "${Stage}-data-template-renderer"
StageName: !Ref Stage
DefinitionBody:
swagger: "2.0"
basePath: !Sub "/${Stage}"
info:
title: !Sub "${Stage}-data-template-renderer"
version: "1.0"
consumes:
- application/json
produces:
- application/json
- text/plain
- application/pdf
paths:
/render:
post:
x-amazon-apigateway-integration:
uri:
"Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RenderTemplate.Arn}/invocations"
httpMethod: POST
type: aws_proxy
x-amazon-apigateway-binary-media-types:
- "*/*"
下面是我用于 Lambda 的代码。请原谅它可能不是您见过的最好的 Golang 代码,但我是 Golang 的初学者,因为我主要是一名 PHP 开发人员,但我工作的公司正在创建很多 Golang lambda,所以我开始学习它。
潇潇雨雨
相关分类