Documentation
¶
Index ¶
- Variables
- type AWSServerlessApi
- type AWSServerlessFunction
- type ServerlessRouter
- func (r *ServerlessRouter) AddAPI(a *cloudformation.AWSServerlessApi) error
- func (r *ServerlessRouter) AddFunction(f *cloudformation.AWSServerlessFunction, handler http.HandlerFunc) error
- func (r *ServerlessRouter) AddStaticDir(dirname string)
- func (r *ServerlessRouter) Mounts() []*ServerlessRouterMount
- func (r *ServerlessRouter) Router() http.Handler
- type ServerlessRouterMount
Constants ¶
This section is empty.
Variables ¶
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 ¶
func (f *AWSServerlessFunction) 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.
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 ¶
func (r *ServerlessRouter) AddAPI(a *cloudformation.AWSServerlessApi) error
AddAPI adds a AWS::Serverless::Api resource to the router, and mounts all of it's API definition
func (*ServerlessRouter) AddFunction ¶
func (r *ServerlessRouter) AddFunction(f *cloudformation.AWSServerlessFunction, handler http.HandlerFunc) error
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')