handlers

package
v0.0.0-...-3f24776 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalancesQuery

type BalancesQuery struct {
	Ids []string `query:"ids[]"`
}

type Handlers

type Handlers struct {
	Db  db.Db
	Log *zap.SugaredLogger
}

Handlers is the overall struct for all http request handlers

func (Handlers) GetStockBalances

func (h Handlers) GetStockBalances(c *fiber.Ctx) error

GetStockBalances godoc @Summary Get stock balances @Description Gets a list of all stock and their balances @ID get-stock-balances @Accept json @Produce json @Param ids[] query string false "Array of ids" @Success 200 {object} map[string]db.StockItem @Failure 500 {object} []ResJSONError @Router /stock-balances [get]

func (Handlers) LogReq

func (h Handlers) LogReq(c *fiber.Ctx) error

Log all requests

func (Handlers) PostAddStockItems

func (h Handlers) PostAddStockItems(c *fiber.Ctx) error

PostAddStockItems godoc @Summary Add stock balances @ID add-balances @Accept json @Produce json @Param body body []db.StockItem true "Array of stock items to add balances to" @Success 200 {string} JSON string "OK" @Failure 400 {object} []ResJSONError @Failure 500 {object} []ResJSONError @Router /add-stock-items [post]

func (Handlers) PostSubtractStockItems

func (h Handlers) PostSubtractStockItems(c *fiber.Ctx) error

PostSubtractStockItems godoc @Summary Subtract stock balances @ID subtract-balances @Accept json @Produce json @Param body body []StockItemAdjuster true "Array of stock items to subtract balance in" @Success 200 {string} JSON string "OK" @Failure 400 {object} []ResJSONError @Failure 500 {object} []ResJSONError @Router /subtract-stock-items [post]

func (Handlers) RequireJSON

func (h Handlers) RequireJSON(c *fiber.Ctx) error

RequireJSON is a middleware that makes sure the request content-type always is application/json (or nothing, defaulting to application/json)

type ResJSONError

type ResJSONError struct {
	Error string `json:"error"`
	Field string `json:"field,omitempty"`
}

ResJSONError is an error field that is used in JSON error responses

type StockItemAdjuster

type StockItemAdjuster struct {
	Amount uint64 `json:"amount"`
	ID     string `json:"id"`
}

Used when adjusting the balance of a StockItem

Jump to

Keyboard shortcuts

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