orderup

package
v0.0.0-...-ec17034 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QUEUES       = "queues"
	ORDERLIST    = "orders"        // Orders list database bucket
	HISTORY      = "history"       // History database bucket
	ORDERCOUNTER = "order_counter" // Indicates the last order id

	V1 = "v1" // Current API version

	// Command set
	CREATE_Q_CMD     = "create-q"
	DELETE_Q_CMD     = "delete-q"
	CREATE_ORDER_CMD = "create-order"
	FINISH_ORDER_CMD = "finish-order"
	LIST_CMD         = "list"
	HISTORY_CMD      = "history"

	SUCCESS_RESPONSE = "success"
	ERROR_RESPONSE   = "error"
)
View Source
const (
	ARG_ERR = iota // Wrong command arguments error
	CMD_ERR        // Command logic error
)

Error types

View Source
const API_PREFIX = "/api"

Variables

This section is empty.

Functions

func NonExistentQueue

func NonExistentQueue(queue string) error

func WrongArgsError

func WrongArgsError() error

Types

type API

type API struct {
	Routes []Route
}

type APIErrorResponse

type APIErrorResponse struct {
	Response string   `json:"response"`
	Errors   []string `json:"errors"`
}

type Cmd

type Cmd struct {
	Name string   // Command name
	Args []string // List of command arguments
}

Command struct.

type Order

type Order struct {
	Username string `json:"username"`
	Order    string `json:"order"`
	Id       int    `json:"id"`
}

func (Order) String

func (o Order) String() string

type Orderup

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

func NewOrderup

func NewOrderup(dbFile, password string) (*Orderup, error)

func (*Orderup) BasicAuth

func (o *Orderup) BasicAuth(pass http.HandlerFunc) http.HandlerFunc

Basic Auth decorate. Decorate API route handler to protect endpoint with token.

func (*Orderup) MakeAPI

func (o *Orderup) MakeAPI(apiVersion string, mux *mux.Router)

Serve web API.

func (*Orderup) MakeRequestHandler

func (o *Orderup) MakeRequestHandler(mux *mux.Router)

Serve Slack API.

func (*Orderup) Shutdown

func (o *Orderup) Shutdown()

Safely close db and shutdown.

type OrderupError

type OrderupError struct {
	ErrType int
	// contains filtered or unexported fields
}

func NewOrderupError

func NewOrderupError(msg string, errType int) *OrderupError

func (*OrderupError) Error

func (e *OrderupError) Error() string

type Route

type Route struct {
	Path        string           // URI endpoint
	HandlerFunc http.HandlerFunc // Handler function
	Methods     []string         // Allowed HTTP methods list
}

Jump to

Keyboard shortcuts

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