pezdispenser

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2015 License: Apache-2.0 Imports: 5 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Type = iota
	Item
	List
	SuccessStatus = "success"
	FailureStatus = "error"
)

Different contexts for rest calls

View Source
const (
	APIVersion1 = "v1"

	ItemGUID = "inventoryItemGUID"
	TypeGUID = "inventoryTypeGUID"
)

Constants to construct routes with

Variables

View Source
var (
	ErrUndefinedPost   = errors.New("You must define a Post() function for your struct that extends Controller")
	ErrUndefinedGet    = errors.New("You must define a Get() function for your struct that extends Controller")
	ErrUndefinedDelete = errors.New("You must define a Delete() function for your struct that extends Controller")
)

Definition of errors for controller

View Source
var (
	URLLeaseBaseV1 = fmt.Sprintf("/%s/%s", APIVersion1, leasePath)
	URLLockBaseV1  = fmt.Sprintf("/%s/%s", APIVersion1, lockPath)
	URLTypeGUID    = fmt.Sprintf("/%s/:%s", typePath, TypeGUID)
	URLItemGUID    = fmt.Sprintf("/%s/:%s", itemPath, ItemGUID)
	URLLeases      = "/list"
)

formatted strings based on constants, to be used in URLs

Functions

func InitAuth

func InitAuth(m martiniUseable)

InitAuth - initializes authentication middleware for controllers

func InitRoutes

func InitRoutes(m *martini.ClassicMartini)

InitRoutes - initialize the mappings for controllers against valid routes

Types

type Controller

type Controller interface {
	Get() interface{}
	Post() interface{}
	Delete() interface{}
}

Controller - This is a controller's interface

func NewLeaseController

func NewLeaseController(version string, category int) (controller Controller)

NewLeaseController - builds a new object of type controller from arguments

func NewLockController

func NewLockController(version string) (controller Controller)

NewLockController - returns a controller interface build using the version argument

type Dispenser

type Dispenser interface {
	GUID() string
	Status() ([]byte, error)
	Lock() ([]byte, error)
	UnLock() ([]byte, error)
	Lease() ([]byte, error)
	Unlease() ([]byte, error)
	Renew() ([]byte, error)
}

Dispenser - a interface for leasable inventory

type DispenserFinder

type DispenserFinder interface {
	GetAll() []Dispenser
	GetByTypeGUID(string) Dispenser
	GetByItemGUID(string) Dispenser
}

DispenserFinder - interfcae for a object to find Dispensers

func NewFinder

func NewFinder() (f DispenserFinder)

NewFinder - returns a DispenserFinder interface

type LeaseItemController

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

LeaseItemController - this is a controller for a lease for a specific item

func (*LeaseItemController) Delete

func (s *LeaseItemController) Delete() (post interface{})

Delete - this will return the versioned controller for a delete rest call

func (*LeaseItemController) Get

func (s *LeaseItemController) Get() (get interface{})

Get - this will return the versioned controller for a get rest call

func (*LeaseItemController) Post

func (s *LeaseItemController) Post() (post interface{})

Post - this will return the versioned controller for a post rest call

type LeaseListController

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

LeaseListController - this is a controller for a lease for a specific type

func (*LeaseListController) Delete

func (s *LeaseListController) Delete() (i interface{})

func (*LeaseListController) Get

func (s *LeaseListController) Get() (get interface{})

Get - this will return the versioned controller for a get rest call

func (*LeaseListController) Post

func (s *LeaseListController) Post() (i interface{})

type LeaseTypeController

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

LeaseTypeController - this is a controller for a lease for a specific type

func (*LeaseTypeController) Delete

func (s *LeaseTypeController) Delete() (i interface{})

func (*LeaseTypeController) Get

func (s *LeaseTypeController) Get() (get interface{})

Get - this will return the versioned controller for a get rest call

func (*LeaseTypeController) Post

func (s *LeaseTypeController) Post() (post interface{})

Post - this will return the versioned controller for a post rest call

type LockController

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

LockController - a controller for locking leases when they hit their expiration date

func (*LockController) Delete

func (s *LockController) Delete() (i interface{})

func (*LockController) Get

func (s *LockController) Get() (post interface{})

Get - returns a versioned controller for get requests

func (*LockController) Post

func (s *LockController) Post() (post interface{})

Post - returns a versioned controller for post requests

type ResponseMessage

type ResponseMessage struct {
	Version string
	Body    []byte
	Status  string
}

ResponseMessage - this is the structure of a response from any call to a controller

Jump to

Keyboard shortcuts

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