go-lambda-linebot

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2018 License: Apache-2.0

README

go-lambda-linebot

GitHub release CircleCI License

go-lambda-linebot provides utility functions to parse AWS Lambda Events and turn them into linebot.Event.

Example

ParseAPIGatewayProxyRequest

ParseAPIGatewayProxyRequest parses events.APIGatewayProxyRequest and turns it into an array of linebot.Event. The implementation of ParseAPIGatewayProxyRequest follows webhook.go in line/line-bot-sdk-go.

package main

import (
	"os"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/shuheiktgw/go-lambda-linebot/parser"
)

func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
	lineEvents, err := parser.ParseAPIGatewayProxyRequest(os.Getenv("CHANNEL_SECRET"), &request)
	
	# Do something useful...
}

func main() {
	lambda.Start(handler)
}
ParseSNSEvent

ParseSNSEvent parses events.SNSEvent and turns it inti linebot.Event. ParseSNSEvent assumes that you provide a single linebot.Event in the Message field of SNS.

package main

import (
	"os"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/shuheiktgw/go-lambda-linebot/parser"
)

func handler(request event events.SNSEvent) error {
	lineEvent, err := parser.ParseSNSEvent(&request)
	
	# Do something useful...
}

func main() {
	lambda.Start(handler)
}

Install

$ go get github.com/shuheiktgw/go-lambda-linebot/parser

Author

Shuhei Kitagawa

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL