apigatewayproxy

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package apigatewayproxy provides a seamless proxy layer which translates Amazon API Gateway requests to Go HTTP requests. By leveraging the Amazon API Gateway Lambda Proxy mode, this package allows to port exsiting Go HTTP applications to Amazon API Gateway & AWS Lambda, without modification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(json.RawMessage, *runtime.Context) (*Response, error)

Handler responds to a Lambda function invocation.

type Response

type Response struct {
	StatusCode      int               `json:"statusCode"`
	Headers         map[string]string `json:"headers,omitempty"`
	Body            string            `json:"body,omitempty"`
	IsBase64Encoded bool              `json:"isBase64Encoded"`
}

Response defines parameters for a well formed response AWS Lambda should return to Amazon API Gateway.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server defines parameters for handling requests coming from Amazon API Gateway. The zero value for Server is not a valid configuration, use New instead.

func New

func New(ln net.Listener, ts []string) *Server

New returns an initialized server to handle requests from Amazon API Gateway. The given media types slice may be nil, if Amazon API Gateway Binary support is not enabled. Otherwise, it should be an array of supported media types as configured in Amazon API Gateway.

func (*Server) Handle

func (s *Server) Handle(evt json.RawMessage, ctx *runtime.Context) (gwres *Response, dummy error)

Handle responds to an AWS Lambda proxy function invocation via Amazon API Gateway. It transforms the Amazon API Gateway Proxy event to a standard HTTP request suitable for the Go net/http package. Then, it submits the data to the network listener so that it can be consumed by HTTP handler. Finally, it waits for the network listener to return response from handler and transmits it back to Amazon API Gateway.

Jump to

Keyboard shortcuts

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