Documentation ¶
Overview ¶
Package classification Product API.
the purpose of this application is to provide an application that is using plain go code to define an API
This should demonstrate all the possible comment annotations that are available to turn go code into a fully compliant swagger 2.0 spec
Documentation for Product API
Schemes: http Host: localhost BasePath: / Version: 0.0.1 Consumes: - application/json Produces: - application/json
swagger:meta
Index ¶
- Variables
- type GenericError
- type KeyProduct
- type Products
- func (p *Products) AddProduct(resp http.ResponseWriter, req *http.Request)
- func (p *Products) DeleteProduct(resp http.ResponseWriter, req *http.Request)
- func (p *Products) GetProductByID(resp http.ResponseWriter, req *http.Request)
- func (p *Products) GetProductList(resp http.ResponseWriter, req *http.Request)
- func (p *Products) MiddlewareValidation(next http.Handler) http.Handler
- func (p *Products) UpdateProduct(resp http.ResponseWriter, req *http.Request)
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidProductPath = fmt.Errorf("Invalid Path, path should be /products/[id]")
ErrInvalidProductPath is an error message when the product path is not valid reserved for 404 ?
Functions ¶
This section is empty.
Types ¶
type GenericError ¶
type GenericError struct {
Message string `json:"message"`
}
GenericError is a generic error message returned by a server
type Products ¶
type Products struct {
// contains filtered or unexported fields
}
Products is a handler for getting and updating products
func NewProductHandler ¶
func NewProductHandler(l hclog.Logger, v *data.Validation, pdb *data.ProductsDB) *Products
NewProductHandler creates a new Products handler
func (*Products) AddProduct ¶
func (p *Products) AddProduct(resp http.ResponseWriter, req *http.Request)
AddProduct is a handler for creating a product
func (*Products) DeleteProduct ¶
func (p *Products) DeleteProduct(resp http.ResponseWriter, req *http.Request)
DeleteProduct is a handler to delete a product
func (*Products) GetProductByID ¶
func (p *Products) GetProductByID(resp http.ResponseWriter, req *http.Request)
GetProductByID is a handler that return a product
func (*Products) GetProductList ¶
func (p *Products) GetProductList(resp http.ResponseWriter, req *http.Request)
GetProductList is a handler that return list of products
func (*Products) MiddlewareValidation ¶
MiddlewareValidation is a middleware handler for product validation before going to the next handler
func (*Products) UpdateProduct ¶
func (p *Products) UpdateProduct(resp http.ResponseWriter, req *http.Request)
UpdateProduct is a handler for updating a product
type ValidationError ¶
type ValidationError struct {
Messages []string `json:"messages"`
}
ValidationError is a collection of validation error messages