Lambda API网关POST参数

时间:2018-10-18 21:46:46

标签: amazon-web-services go aws-lambda

我正在尝试从此简单的Lambda中将其作为键值访问

package main

import (
    "github.com/aws/aws-lambda-go/events"
    "github.com/aws/aws-lambda-go/lambda"
    "net/http"
)


func Draw(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {

    return events.APIGatewayProxyResponse{
        StatusCode: http.StatusOK,
        Body:       "Draw API " + request.Body,
    }, nil
}

func main() {
    // https://www.alexedwards.net/blog/serverless-api-with-go-and-aws-lambda

    lambda.Start(Draw)
}

并具有简单的卷曲感

curl -d "timestamp=11223344" https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/api/draw

我知道

Draw API timestamp=11223344

如何获取具有参数名称和值的键/值字符串或映射?不幸的是我不能使用json作为输入

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用net/url.ParseQuery

import "net/url"

...

kv, err := url.ParseQuery("foo=bar")