How to Migrate a #go API to #serverless (in under 10 mins)
▻https://hackernoon.com/how-to-migrate-a-go-api-to-serverless-in-under-10-mins-e27b8a31202e?sour
I’m going to step you through the process converting an existing Go API to serverless and deploying it to to #aws Lambda & API Gateway with AWS Severless Application Model (SAM). The whole process should take under 10 minutes. Let’s get started!1. SetupOur example API uses the HttpRouter package so let’s install that first.$ go get github.com/julienschmidt/httprouterWe have a single HTTP handler defined that will return a 200 HTTP response with the body ok.# handlers.gopackage mainimport "net/http"func HealthHandler(w http.ResponseWriter, r *http.Request) w.WriteHeader(http.StatusOK) w.Write([]byte("ok"))Our entrypoint to the application, the main function, attaches the HealthHandler to the /healthz route and listens for HTTP requests on port 8080.# (...)