Documentation ¶
Index ¶
Constants ¶
const ( Type = iota Item List SuccessStatus = "success" FailureStatus = "error" )
Different contexts for rest calls
const ( APIVersion1 = "v1" ItemGUID = "inventoryItemGUID" TypeGUID = "inventoryTypeGUID" )
Constants to construct routes with
Variables ¶
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
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) Get ¶
func (s *LeaseListController) Get() (get interface{})
Get - this will return the versioned controller for a get rest call
type LeaseTypeController ¶
type LeaseTypeController struct {
// contains filtered or unexported fields
}
LeaseTypeController - this is a controller for a lease for a specific type
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) 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 ¶
ResponseMessage - this is the structure of a response from any call to a controller