百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

algnhsa

> 编程语言
开源

AWS Lambda Go 网络 http 服务器适配器

394 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

AWS Lambda Go 网络 http 服务器适配器

algnhsa

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

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

…

Plug in a third-party web framework

Gin

go
package main

import (
	"net/http"

	"github.com/akrylysov/algnhsa"
	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	r.GET("/", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": "hi",
		})
	})
	algnhsa.ListenAndServe(r, nil)
}

echo

go
package main

import (
	"net/http"

	"github.com/akrylysov/algnhsa"
	"github.com/labstack/echo/v4"
)

func main() {
	e := echo.New()
	e.GET("/", func(c echo.Context) error {
		return c.String(http.StatusOK, "hi")
	})
	algnhsa.ListenAndServe(e, nil)
}

chi

go
package main

import (
	"net/http"

	"github.com/akrylysov/algnhsa"
	"github.com/go-chi/chi"
)

func main() {
	r := chi.NewRouter()
	r.Get("/", func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hi"))
	})
	algnhsa.ListenAndServe(r, nil)
}

Fiber

go
package main

import (
	"github.com/akrylysov/algnhsa"
	"github.com/gofiber/fiber/v2"
	"github.com/gofiber/fiber/v2/middleware/adaptor"
)

func main() {
	app := fiber.New()
	app.Get("/", func(c *fiber.Ctx) error {
		return c.SendString("Hello, World!")
	})
	algnhsa.ListenAndServe(adaptor.FiberApp(app), nil)
}

Deployment

First, build your Go application for Linux and zip it:

bash
GOOS=linux GOARCH=amd64 go build -tags lambda.norpc -o bootstrap
zip function.zip bootstrap

When creating a new function, choose the "Provide your own bootstrap on Amazon Linux 2" runtime or "Custom runtime on Amazon Linux 2" when modifying an existing function. Make sure to use bootstrap as the executable name and as the handler name in AWS.

AWS provides plenty of ways to expose a Lambda function to the internet.

Lambda Function URL

This is the easier way to deploy your Lambda function as an HTTP endpoint. It only requires going to the "Function URL" section of the Lambda function configuration and clicking "Configure Function URL".

API Gateway

HTTP API

  1. Create a new HTTP API.

  2. Configure a catch-all $default route.

REST API

  1. Create a new REST API.

  2. In the "Resources" section create a new ANY method to handle requests to / (check "Use Lambda Proxy Integration").

  3. Add a catch-all {proxy+} resource to handle requests to every other path (check "Configure as proxy resource").

ALB

  1. Create a new ALB and point it to your Lambda function.

  2. In the target group settings in the "Attributes" section enable "Multi value headers".

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goawsaws-lambdagolambda

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言