Created
January 21, 2017 09:50
-
-
Save wolfeidau/643a226e2d047b4b6206d90e45e38ff5 to your computer and use it in GitHub Desktop.
Road testing https://github.com/eawsy/aws-lambda-go-net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
Function: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: handler.Handle | |
Runtime: python2.7 | |
CodeUri: ../cloudbookmarks.zip | |
Events: | |
ApiRoot: | |
Type: Api | |
Properties: | |
Path: /{proxy+} | |
Method: ANY | |
Outputs: | |
URL: | |
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// /* Required, but no C code needed. */ | |
import "C" | |
import ( | |
"net/http" | |
"github.com/eawsy/aws-lambda-go-net/service/lambda/runtime/net" | |
"github.com/eawsy/aws-lambda-go-net/service/lambda/runtime/net/apigatewayproxy" | |
"github.com/gin-gonic/gin" | |
) | |
// Handle is the exported handler called by AWS Lambda. | |
var Handle apigatewayproxy.Handler | |
func handle(ctx *gin.Context) { | |
ctx.String(http.StatusOK, "OK", ctx.Param("name")) | |
} | |
func init() { | |
listener := net.Listen() | |
// Amazon API Gateway Binary support out of the box. | |
Handle = apigatewayproxy.New(listener, nil).Handle | |
r := gin.Default() | |
r.GET("/health", handle) | |
go http.Serve(listener, r) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment