Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Created January 21, 2017 09:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfeidau/643a226e2d047b4b6206d90e45e38ff5 to your computer and use it in GitHub Desktop.
Save wolfeidau/643a226e2d047b4b6206d90e45e38ff5 to your computer and use it in GitHub Desktop.
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"
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