lifadev / archive_aws-lambda-go-event

Type definitions for AWS Lambda event sources.
https://github.com/eawsy/aws-lambda-go-event
Apache License 2.0
77 stars 18 forks source link

How respond in json to API Gateway Proxy Events?? #4

Closed livzz closed 6 years ago

livzz commented 6 years ago

No examples

fsenart commented 6 years ago

Hi @livzz, If you intend to use API Gateway Proxy please refer to https://github.com/eawsy/aws-lambda-go-net which provides full featured http server capability behind API Gateway. Otherwise here is a very simple example for API Gateway Proxy:

package main

import (
    "github.com/eawsy/aws-lambda-go-core/service/lambda/runtime"
    "github.com/eawsy/aws-lambda-go-event/service/lambda/runtime/event/apigatewayproxyevt"
)

func Handle(evt *apigatewayproxyevt.Event, ctx *runtime.Context) (interface{}, error) {
    return map[string]interface{}{
        "statusCode": 200,
        "body":       "Helo, World!",
    }, nil
}