adaptor

package module
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

lambda-http-adaptor

Go Reference GitHub

lambda-http-adaptor is a compatible adaptor for Go net/http that can be used in multiple serverless environments.

You can run your existing http.HandlerFunc compatible web application on AWS Lambda or Azure Functions.

Example

lambda-http-adaptor provides the adaptor.ListenAndServe method, which can drop-in replacement for the http.ListenAndServe.

package main

import (
	"github.com/yacchi/lambda-http-adaptor"
	_ "github.com/yacchi/lambda-http-adaptor/all"
	"log"
	"net/http"
)

func main() {
	log.Fatalln(adaptor.ListenAndServe("", http.HandlerFunc(echoReplyHandler)))
}

func echoReplyHandler(w http.ResponseWriter, r *http.Request) {
	m := r.URL.Query().Get("message")
	w.Header().Set("Content-Type", "text/plain")
	w.Write([]byte(m))
}

Pass through non-http events

Pass-through of non-HTTP Events has been added in v0.5.0. The destination path is /events by default. If you want to change the forwarding path or stop forwarding, please refer to the following sample for configuration.

func main() {
  log.Fatalln(adaptor.ListenAndServeWithOptions(
    "",
    handler,
    // aws.WithNonHTTPEventPath("/api"),
	// aws.WithoutNonHTTPEventPassThrough(),
  )
}

Features

  • AWS Lambda support
    • API Gateway REST API integration
      • Multi-value headers
      • Multi-value query string
      • Get ProxyRequestContext value from Context
    • API Gateway HTTP API integration
      • Multi-value headers
      • Get V2 HTTPRequestContext value from Context
    • Application Load Balancer Lambda target
      • Multi-value headers
      • Get ALBTargetGroupRequestContext value from Context
    • Get raw request value from Context
    • Lambda container image function
    • API Gateway Websocket API integration (Experimental)
    • Non-HTTP event pass-through
  • AWS API Gateway utilities
    • Strip stage var middleware
    • Abstract interface of RequestContext
  • Azure Functions support
    • HTTP Trigger with custom handler

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(addr string, h http.Handler) error

func ListenAndServeWithOptions added in v0.3.0

func ListenAndServeWithOptions(addr string, h http.Handler, opts ...interface{}) error

Types

This section is empty.

Directories

Path Synopsis
Package aws provides an implementation using aws-sdk-go.
Package aws provides an implementation using aws-sdk-go.
example
simple command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL