一个无缝的方式执行Go web应用程序在AWS Lambda和AWS API 网关
一个无缝的方式执行Go web应用程序在AWS Lambda和AWS API 网关
Go Web框架
共152Star
详细介绍
eawsy/aws-lambda-go-net
A seamless way to execute Go web applications on AWS Lambda and AWS API Gateway.
AWS Lambda lets you run code without provisioning or managing servers. AWS API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale.
This projects provides an AWS Lambda network interface for Go. You can leverage AWS Lambda and AWS API Gateway to handle web requests using any Go application framework.
Preview
Below are some examples with popular Go frameworks. These examples are not exhaustive. You are free to use anything you want!
go get -u -d github.com/eawsy/aws-lambda-go-net/...
Go
Usingpackage main
import (
"net/http"
"github.com/eawsy/aws-lambda-go-net/service/lambda/runtime/net"
)
func handle(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World!"))
}
func init() {
go http.Serve(net.Listener(), http.HandlerFunc(handle))
}
func main() {}
Gin
Usinggo get gopkg.in/gin-gonic/gin.v1
package main
import (
"net/http"
"github.com/eawsy/aws-lambda-go-net/service/lambda/runtime/net"
"github.com/gin-gonic/gin"
)
func handle(ctx *gin.Context) {
ctx.String(http.StatusOK, "Hello, %s!", ctx.Param("name"))
}
func init() {
r := gin.Default()
r.GET("/hello/:name", handle)
go http.Serve(net.Listener(), r)
}
func main() {}
Gorilla
Usinggo get -u github.com/gorilla/mux
package main
import (
"fmt"
"net/http"
"github.com/eawsy/aws-lambda-go-net/service/lambda/runtime/net"
"github.com/gorilla/mux"
)
func handle(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf("Hello, %s!", mux.Vars(r)["name"])))
}
func init() {
r := mux.NewRouter()
r.HandleFunc("/hello/{name}", handle)
go http.Serve(net.Listener(), r)
}
func main() {}
Documentation
This wiki is the main source of documentation for developers working with or contributing to the project.
About
This project is maintained and funded by Alsanium, SAS.
We
License
This product is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this product except in compliance with the License. See LICENSE and NOTICE for more information.
Trademark
Alsanium, eawsy, the "Created by eawsy" logo, and the "eawsy" logo are trademarks of Alsanium, SAS. or its affiliates in France and/or other countries.
Amazon Web Services, the "Powered by Amazon Web Services" logo, and AWS Lambda are trademarks of Amazon.com, Inc. or its affiliates in the United States and/or other countries.
-
268 Star
-
711 Star
-
6075 Star
-
806 Star