router

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEventsFound = errors.New("no events with type 'Api' were found")

ErrNoEventsFound is thrown if a AWS::Serverless::Function is added to this router, but no API event sources exist for it.

Functions

This section is empty.

Types

type AWSServerlessApi

type AWSServerlessApi struct {
	*cloudformation.AWSServerlessApi
}

AWSServerlessApi wraps GoFormation's AWS::Serverless::Api definition and adds some convenience methods for extracting the ServerlessRouterMount's from the swagger defintion etc.

func (*AWSServerlessApi) Mounts

func (api *AWSServerlessApi) Mounts() ([]*ServerlessRouterMount, error)

Mounts fetches an array of the ServerlessRouterMount's for this API. These contain the path, method and handler function for each mount point.

func (*AWSServerlessApi) Swagger

func (api *AWSServerlessApi) Swagger() ([]byte, error)

Swagger gets the swagger definition for the API. Returns the swagger definition as a []byte of JSON.

type AWSServerlessFunction

type AWSServerlessFunction struct {
	*cloudformation.AWSServerlessFunction
	// contains filtered or unexported fields
}

AWSServerlessFunction wraps GoFormation's AWS::Serverless::Function definition and adds some convenience methods for extracting the ServerlessRouterMount's from the event sources.

func (*AWSServerlessFunction) Mounts

Mounts fetches an array of the ServerlessRouterMount's for this API. These contain the path, method and handler function for each mount point.

type ServerlessRouter

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

ServerlessRouter takes AWS::Serverless::Function and AWS::Serverless::API objects and creates a Go http.Handler with the correct paths/methods mounted

func NewServerlessRouter

func NewServerlessRouter() *ServerlessRouter

NewServerlessRouter creates a new instance of ServerlessRouter

func (*ServerlessRouter) AddAPI

AddAPI adds a AWS::Serverless::Api resource to the router, and mounts all of it's API definition

func (*ServerlessRouter) AddFunction

AddFunction adds a AWS::Serverless::Function to the router and mounts all of it's event sources that have type 'Api'

func (*ServerlessRouter) AddStaticDir

func (r *ServerlessRouter) AddStaticDir(dirname string)

AddStaticDir mounts a static directory provided, at the mount point also provided

func (*ServerlessRouter) Mounts

func (r *ServerlessRouter) Mounts() []*ServerlessRouterMount

Mounts returns a list of the mounts associated with this router

func (*ServerlessRouter) Router

func (r *ServerlessRouter) Router() http.Handler

Router returns the Go http.Handler for the router, to be passed to http.ListenAndServe()

type ServerlessRouterMount

type ServerlessRouterMount struct {
	Name     string
	Function *AWSServerlessFunction
	Handler  http.HandlerFunc
	Path     string
	Method   string
}

ServerlessRouterMount represents a single mount point on the API Such as '/path', the HTTP method, and the function to resolve it

func (*ServerlessRouterMount) Methods

func (m *ServerlessRouterMount) Methods() []string

Methods gets an array of HTTP methods from a AWS::Serverless::Function API event source method declaration (which could include 'any')

Jump to

Keyboard shortcuts

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