sam local start-api为什么不转换http请求

时间:2019-05-17 22:35:16

标签: amazon-web-services aws-lambda aws-api-gateway

我使用case WM_TIMER: { if (divisible % 15 == 0) { KillTimer (hwnd, 1); MessageBox (hwnd, "a", "a", MB_ABORTRETRYIGNORE | MB_ICONASTERISK); SetTimer (hwnd, 1, 50, NULL); } divisible++; break; } 在本地启动我的Lambda。我使用此命令sam local start-api将带有JSON数据的POST请求发送到此lambda。

curl --request POST -H "Content-Type: application/json" http://localhost:3000/hello

该事件被打印为http请求对象,例如:

exports.lambdaHandler = async (event, context) => {
    console.log('event body:', event);
    try {
        // const ret = await axios(url);
        response = {
            'statusCode': 200,
            'body': JSON.stringify({
                message: 'hello world',
                // location: ret.data.trim()
            })
        }
    } catch (err) {
        console.log(err);
        return err;
    }

    return response
};

但是,当我将函数部署到lambda并通过API-GATEWAY发送请求时,打印的数据为正文 body: '{"url": "http://"}', resource: '/hello', requestContext: ... 。 我看起来API Gateway会对请求进行转换,但本地服务器不会。如何使本地服务器以与API网关相同的方式运行?

下面是SAM模板文件:

{"url": "http://"}

0 个答案:

没有答案