Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 在AWS::Serverless::Api SAM模板中定义URL查询字符串参数_Amazon Web Services_Aws Api Gateway_Aws Serverless_Aws Sam - Fatal编程技术网

Amazon web services 在AWS::Serverless::Api SAM模板中定义URL查询字符串参数

Amazon web services 在AWS::Serverless::Api SAM模板中定义URL查询字符串参数,amazon-web-services,aws-api-gateway,aws-serverless,aws-sam,Amazon Web Services,Aws Api Gateway,Aws Serverless,Aws Sam,如何为SAM模板中的AWS::Serverless::Api定义和验证URL查询字符串参数 文档中似乎没有提到它们 我想说清楚这就是我要说的 我认为您的响应在另一个资源AWS::ApiGateway::Method中 检查文档(搜索请求参数): API网关接受的请求参数。将请求参数指定为键值对(字符串到布尔映射),以源作为键,以布尔值作为值。布尔值指定是否需要参数。源必须与method.request.location.name格式匹配,其中位置为querystring、path或header,

如何为SAM模板中的AWS::Serverless::Api定义和验证URL查询字符串参数

文档中似乎没有提到它们

我想说清楚这就是我要说的

我认为您的响应在另一个资源AWS::ApiGateway::Method中

检查文档(搜索请求参数):

API网关接受的请求参数。将请求参数指定为键值对(字符串到布尔映射),以源作为键,以布尔值作为值。布尔值指定是否需要参数。源必须与method.request.location.name格式匹配,其中位置为querystring、path或header,并且名称是有效的唯一参数名称


URL查询字符串参数是在AWS::Serverless::函数中定义的,而不是使用RequestParameters属性在AWS::Serverless::Api中定义的

例如,要将邮件、姓名、电话定义为URL查询字符串参数,可以执行以下操作:

Events:
  ApiEvent:
  Type: Api
  Properties:
    Path: /path
    Method: get
    RequestParameters:
      - method.request.querystring.mail:
          Required: true
          Caching: true
      - method.request.querystring.name:
          Required: true
          Caching: true
      - method.request.querystring.phone:
          Required: false
          Caching: false
method.request.header.{{header_name}}
// For example: method.request.header.Authorization
您还可以使用以下内容定义HTTP请求头:

Events:
  ApiEvent:
  Type: Api
  Properties:
    Path: /path
    Method: get
    RequestParameters:
      - method.request.querystring.mail:
          Required: true
          Caching: true
      - method.request.querystring.name:
          Required: true
          Caching: true
      - method.request.querystring.phone:
          Required: false
          Caching: false
method.request.header.{{header_name}}
// For example: method.request.header.Authorization

我希望这会有所帮助。

请在您的问题中添加您的模板yaml/json