proxy

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Unlicense Imports: 10 Imported by: 0

README

API Gateway HTTP Proxy

Project Setup

main.go
package main

import (
  "github.com/aws/aws-lambda-go/lambda"
  "github.com/gin-gonic/gin"
  proxy "github.com/maddiesch/api-gateway-proxy"
)

var (
  app *gin.Engine
)

func init() {
  app = gin.New()
}

func main() {
  lambda.Start(proxy.Handler(app))
}

template.yml
Transform: AWS::Serverless-2016-10-31
Globals:
  Function:
    Runtime: provided.al2
    Timeout: 30
    MemorySize: 256
Resources:
  ApiResource:
    Type: AWS::Serverless::HttpApi
  AppFunctionHandler:
    Type: AWS::Serverless::Function
    Properties:
      CodeUri: bin/app_handler/
      Handler: bootstrap
      Events:
        RootRequestEvent:
          Type: HttpApi
          Properties:
            ApiId: !Ref ApiResource
            Method: any
            Path: /
        PathRequestEvent:
          Type: HttpApi
          Properties:
            ApiId: !Ref ApiResource
            Method: any
            Path: /{path+}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InternalServerErrorResponse

func InternalServerErrorResponse() events.APIGatewayV2HTTPResponse

InternalServerErrorResponse returns a standard 500 error response

func NewResponseWriter

func NewResponseWriter() http.ResponseWriter

NewResponseWriter returns a new ResponseWriter for the request

func RequestForEvent

func RequestForEvent(e events.APIGatewayV2HTTPRequest) (*http.Request, error)

RequestForEvent converts the APIGatewayV2HTTPRequest into a standard golang http.Request

Types

type HandlerFunc

HandlerFunc is the function interface for proxying API Gateway events to standard http.Handler

func Handler

func Handler(handler http.Handler) HandlerFunc

Handler converts the APIGatewayV2HTTPRequest into a standard golang http.Request and provides a simple writer.

Jump to

Keyboard shortcuts

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