Package rest provides a set of utility functions to make building REST-based services simpler. See the project for a complete example.



    This section is empty.


    This section is empty.


    func RegisterResource

    func RegisterResource(apiGateway *sparta.API, resource Resource) ([]*sparta.LambdaAWSInfo, error)

      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


      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

              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 *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

                        Source Files