rest

package
Version: v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

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

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

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL