Skip to content

tomodian/algnhsa

 
 

Repository files navigation

algnhsa GoDoc Build Status

algnhsa is an AWS Lambda Go net/http server adapter.

algnhsa enables running Go web applications on AWS Lambda/API Gateway without changing the existing HTTP handlers:

package main

import (
    "fmt"
    "net/http"
    "strconv"

    "github.com/akrylysov/algnhsa"
)

func indexHandler(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("index"))
}

func addHandler(w http.ResponseWriter, r *http.Request) {
    f, _ := strconv.Atoi(r.FormValue("first"))
    s, _ := strconv.Atoi(r.FormValue("second"))
    w.Header().Set("X-Hi", "foo")
    fmt.Fprintf(w, "%d", f+s)
}

func main() {
    http.HandleFunc("/", indexHandler)
    http.HandleFunc("/add", addHandler)
    algnhsa.ListenAndServe(http.DefaultServeMux, nil)
}

More details at http://artem.krylysov.com/blog/2018/01/18/porting-go-web-applications-to-aws-lambda/.

About

AWS Lambda Go net/http server adapter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%