更新时间:2023-08-09 GMT+08:00
分享

测试函数

  1. 测试托管方式改造函数,调用方法如图1所示。
    图1 测试函数调用的方法
    • 调用时,遵循原来的请求方法。
    • 请求url为添加事件源创建的APIG触发器地址。
    • 需要在headers里配置requestPath,值为图1中的@Path(可能会包含一些服务前缀,对应微服务改造之前的请求Path即可),如图2所示。
      图2 requestPath配置
  2. 测试独立函数。
    • 统一使用POST请求。
    • 请求url为添加事件源创建的APIG触发器地址。
    • Body体参考如下格式进行配置,如图3所示,在函数代码中可以根据需要,通过APIGTriggerEvent对象获取相应的值。
      图3 Body体
      {
          "body": "xxxxxx",
          "requestContext": {
              "apiId": "xxxx",
              "requestId": "xxxxx",
              "stage": "RELEASE"
          },
          "queryStringParameters": {
              "responseType": "html"
          },
          "httpMethod": "POST",
          "pathParameters": {},
          "headers": {
              "accept-language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
              "accept-encoding": "gzip, deflate, br",
              "x-forwarded-port": "443",
              "x-forwarded-for": "xxxxxx",
              "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
              "upgrade-insecure-requests": "1",
              "host": "xxxxxxxx",
              "x-forwarded-proto": "https",
              "pragma": "no-cache",
              "cache-control": "no-cache",
              "x-real-ip": "xxxxxxxx",
              "user-agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0"
          },
          "path": "",
          "isBase64Encoded": true
      }
分享:

    相关文档

    相关产品