lambdarouter

package module
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

README

lambdarouter

GoDoc Reference Build Status Test Coverage Maintainability Go Report Card

This package will become a fully featured AWS Lambda function router, able to respond to HTTP, Schedule, Cognito, and SNS events. It will also support middleware interfacing.

So far it includes functionality for API Gateway. Check out the GoDoc Reference to see how to instantiate a router and create endpoints.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIGContext

type APIGContext struct {
	Claims  map[string]interface{}
	Context context.Context
	Path    map[string]string
	QryStr  map[string]string
	Request *events.APIGatewayProxyRequest
	Status  int
	Body    []byte
	Err     error
}

APIGContext is used as the input and output of handler functions. The Body, Claims, Path, and QryStr will be populated by the the APIGatewayProxyRequest. The Request itself is also passed through if you need further access. Fill the Status and Body, or Status and Error to respond.

type APIGHandler

type APIGHandler func(ctx *APIGContext)

APIGHandler is the interface a handler function must implement to be used with Get, Post, Put, Patch, and Delete.

type APIGRouter

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

APIGRouter is the object that handlers build upon and is used in the end to respond.

func NewAPIGRouter

func NewAPIGRouter(cfg *APIGRouterConfig) *APIGRouter

NewAPIGRouter creates a new router using the given router config.

func (*APIGRouter) Delete

func (r *APIGRouter) Delete(route string, handlers ...APIGHandler)

Delete creates a new delete endpoint.

func (*APIGRouter) Get

func (r *APIGRouter) Get(route string, handlers ...APIGHandler)

Get creates a new get endpoint.

func (*APIGRouter) Patch

func (r *APIGRouter) Patch(route string, handlers ...APIGHandler)

Patch creates a new patch endpoint

func (*APIGRouter) Post

func (r *APIGRouter) Post(route string, handlers ...APIGHandler)

Post creates a new post endpoint.

func (*APIGRouter) Put

func (r *APIGRouter) Put(route string, handlers ...APIGHandler)

Put creates a new put endpoint.

func (*APIGRouter) Respond

Respond returns an APIGatewayProxyResponse to respond to the lambda request.

type APIGRouterConfig

type APIGRouterConfig struct {
	Context context.Context
	Request *events.APIGatewayProxyRequest
	Prefix  string
	Headers map[string]string
}

APIGRouterConfig is used as the input to NewAPIGRouter, request is your incoming apig request and prefix will be stripped of all incoming request paths. Headers will be sent with all responses.

Jump to

Keyboard shortcuts

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