Documentation ¶
Index ¶
- Variables
- type AuthHandler
- type Handler
- func (h *Handler) CreateCompany(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateContract(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteCompany(w http.ResponseWriter, r *http.Request)
- func (h *Handler) DeleteContract(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetCompany(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetCompanyList(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetContract(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetContractList(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetPurchaseHistory(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Purchase(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateCompany(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateContract(w http.ResponseWriter, r *http.Request)
- type ResponseID
- type Server
Constants ¶
This section is empty.
Variables ¶
var ( // ErrContractNotFound contract doesn't exist in DB ErrContractNotFound = errors.New("contract doesn't exist") // ErrSellerNotExist seller company doesn't exist in DB ErrSellerNotExist = errors.New("seller company doesn't exist") // ErrClientNotExist client company doesn't exist in DB ErrClientNotExist = errors.New("client company doesn't exist") // ErrDateNotValid purchase date is outside the contract date range ErrDateNotValid = errors.New("purchase date is outside the contract date range") // ErrNotEnoughMoney not enough money for the purchase ErrNotEnoughMoney = errors.New("not enough money for the purchase") )
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶
type AuthHandler struct { jwtmiddleware.JWTMiddleware // contains filtered or unexported fields }
AuthHandler authentication handler
func NewAuthHandler ¶
func NewAuthHandler(key []byte) *AuthHandler
NewAuthHandler creates new authentication handler
func (*AuthHandler) GenerateToken ¶
func (a *AuthHandler) GenerateToken(w http.ResponseWriter, r *http.Request)
GenerateToken returns new authentication token
func (*AuthHandler) HandlerFunc ¶
func (a *AuthHandler) HandlerFunc(f func(w http.ResponseWriter, r *http.Request)) http.Handler
HandlerFunc is a function handler adepter that wraps handler function into auth handler object
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a request handler
func NewHandler ¶
func NewHandler(company model.CompanyModel, contract model.ContractModel, purchase model.PurchaseModel) *Handler
NewHandler returns new request handler
func (*Handler) CreateCompany ¶
func (h *Handler) CreateCompany(w http.ResponseWriter, r *http.Request)
CreateCompany creates new company
func (*Handler) CreateContract ¶
func (h *Handler) CreateContract(w http.ResponseWriter, r *http.Request)
CreateContract creates new contract
func (*Handler) DeleteCompany ¶
func (h *Handler) DeleteCompany(w http.ResponseWriter, r *http.Request)
DeleteCompany removes company
func (*Handler) DeleteContract ¶
func (h *Handler) DeleteContract(w http.ResponseWriter, r *http.Request)
DeleteContract removes contract
func (*Handler) GetCompany ¶
func (h *Handler) GetCompany(w http.ResponseWriter, r *http.Request)
GetCompany returns company info
func (*Handler) GetCompanyList ¶
func (h *Handler) GetCompanyList(w http.ResponseWriter, r *http.Request)
GetCompanyList returns list of companies
func (*Handler) GetContract ¶
func (h *Handler) GetContract(w http.ResponseWriter, r *http.Request)
GetContract returns contract data
func (*Handler) GetContractList ¶
func (h *Handler) GetContractList(w http.ResponseWriter, r *http.Request)
GetContractList returns contract list
func (*Handler) GetPurchaseHistory ¶
func (h *Handler) GetPurchaseHistory(w http.ResponseWriter, r *http.Request)
GetPurchaseHistory returns purcase history of contract
func (*Handler) Purchase ¶
func (h *Handler) Purchase(w http.ResponseWriter, r *http.Request)
Purchase creates new purchase document
func (*Handler) UpdateCompany ¶
func (h *Handler) UpdateCompany(w http.ResponseWriter, r *http.Request)
UpdateCompany updates company data
func (*Handler) UpdateContract ¶
func (h *Handler) UpdateContract(w http.ResponseWriter, r *http.Request)
UpdateContract updates contract