MCPcopy Index your code
hub / github.com/apex/gateway

github.com/apex/gateway @v2.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.0 ↗ · + Follow
77 symbols 285 edges 14 files 34 documented · 44% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Package gateway provides a drop-in replacement for net/http's ListenAndServe for use in AWS Lambda & API Gateway, simply swap it out for gateway.ListenAndServe. Extracted from Up which provides additional middleware features and operational functionality.

There are two versions of this library, version 1.x supports AWS API Gateway 1.0 events used by the original REST APIs, and 2.x which supports 2.0 events used by the HTTP APIs. For more information on the options read Choosing between HTTP APIs and REST APIs on the AWS documentation website.

Installation

To install version 1.x for REST APIs.

go get github.com/apex/gateway

To install version 2.x for HTTP APIs.

go get github.com/apex/gateway/v2

Example

package main

import (
    "fmt"
    "log"
    "net/http"
    "os"

    "github.com/apex/gateway"
)

func main() {
    http.HandleFunc("/", hello)
    log.Fatal(gateway.ListenAndServe(":3000", nil))
}

func hello(w http.ResponseWriter, r *http.Request) {
    // example retrieving values from the api gateway proxy request context.
    requestContext, ok := gateway.RequestContext(r.Context())
    if !ok || requestContext.Authorizer["sub"] == nil {
        fmt.Fprint(w, "Hello World from Go")
        return
    }

    userID := requestContext.Authorizer["sub"].(string)
    fmt.Fprintf(w, "Hello %s from Go", userID)
}

GoDoc

Core symbols most depended-on inside this repo

Header
called by 13
response.go
Header
called by 13
v2/response.go
NewRequest
called by 12
v2/request.go
NewRequest
called by 11
request.go
NewResponse
called by 7
response.go
isTextMime
called by 7
response.go
NewResponse
called by 7
v2/response.go
isTextMime
called by 7
v2/response.go

Shape

Function 59
Method 12
Struct 4
TypeAlias 2

Languages

Go100%

Modules by API surface

v2/request_test.go11 symbols
request_test.go10 symbols
v2/response.go9 symbols
response.go9 symbols
v2/response_test.go8 symbols
response_test.go8 symbols
v2/gateway.go4 symbols
gateway.go4 symbols
v2/gateway_test.go3 symbols
v2/context.go3 symbols
gateway_test.go3 symbols
context.go3 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add gateway \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact