lambdarouter

package module
v0.0.3-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 5 Imported by: 1

README

lambdarouter GoDoc Reference Build Status Coverage Status 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 APIGHandler

type APIGHandler func(req *APIGRequest, res *APIGResponse)

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

type APIGRequest

type APIGRequest struct {
	Body    string
	Claims  map[string]interface{}
	Path    map[string]string
	QryStr  map[string]string
	Request *events.APIGatewayProxyRequest
}

APIGRequest is used as the input of handler functions. The Claims, Path, and QryStr will be populated by the the APIGatewayProxyRequest. The Request itself is also passed through if you need further access.

type APIGResponse

type APIGResponse struct {
	Status int
	Body   []byte
	Err    error
}

APIGResponse is used as the output of handler functions. Populate Status and Body with your http response or populate Err with your error.

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(r *events.APIGatewayProxyRequest, svcprefix string) *APIGRouter

NewAPIGRouter creates a new router using the request and a prefix to strip from your incoming requests.

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.

Jump to

Keyboard shortcuts

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