Documentation ¶
Overview ¶
Package rest provides a set of utility functions to make building REST-based services simpler. See the https://github.com/mweagle/SpartaTodoBackend project for a complete example.
Index ¶
- func RegisterResource(apiGateway *sparta.API, resource Resource) ([]*sparta.LambdaAWSInfo, error)
- type MethodHandler
- func (mh *MethodHandler) Headers(headerNames ...string) *MethodHandler
- func (mh *MethodHandler) Options(options *sparta.LambdaFunctionOptions) *MethodHandler
- func (mh *MethodHandler) Privileges(privileges ...sparta.IAMRolePrivilege) *MethodHandler
- func (mh *MethodHandler) StatusCodes(codes ...int) *MethodHandler
- type MethodHandlerMap
- type Resource
- type ResourceDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterResource ¶
RegisterResource creates a set of lambda handlers for the given resource and registers them with the apiGateway. The sparta Lambda handler returned slice is eligible
Types ¶
type MethodHandler ¶
type MethodHandler struct { DefaultCode int Handler interface{} // contains filtered or unexported fields }
MethodHandler represents a handler for a given HTTP method
func NewMethodHandler ¶
func NewMethodHandler(handler interface{}, defaultCode int) *MethodHandler
NewMethodHandler is a constructor function to return a new MethodHandler pointer instance.
func (*MethodHandler) Headers ¶
func (mh *MethodHandler) Headers(headerNames ...string) *MethodHandler
Headers is the fluent builder that defines what headers this method returns
func (*MethodHandler) Options ¶
func (mh *MethodHandler) Options(options *sparta.LambdaFunctionOptions) *MethodHandler
Options is a fluent builder that allows customizing the lambda execution options for the given function
func (*MethodHandler) Privileges ¶
func (mh *MethodHandler) Privileges(privileges ...sparta.IAMRolePrivilege) *MethodHandler
Privileges is the fluent builder to associated IAM privileges with this HTTP handler
func (*MethodHandler) StatusCodes ¶
func (mh *MethodHandler) StatusCodes(codes ...int) *MethodHandler
StatusCodes is a fluent builder to append additional HTTP status codes for the given MethodHandler. It's primarily used to disamgiguate input from the NewMethodHandler constructor
type MethodHandlerMap ¶
type MethodHandlerMap map[string]*MethodHandler
MethodHandlerMap is a map of http method names to their handlers
type Resource ¶
type Resource interface {
ResourceDefinition() (ResourceDefinition, error)
}
Resource defines the interface an object must define in order to provide a ResourceDefinition
type ResourceDefinition ¶
type ResourceDefinition struct { URL string MethodHandlers MethodHandlerMap }
ResourceDefinition represents a set of handlers for a given URL path