Documentation ¶
Overview ¶
Package classification of gomicro Product API
Documentation for gomicro Product API
Schemes: http BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - application/json
swagger:meta
Index ¶
- Variables
- type GenericError
- type KeyProduct
- type Products
- func (p *Products) Create(w http.ResponseWriter, r *http.Request)
- func (p *Products) Delete(w http.ResponseWriter, r *http.Request)
- func (p *Products) ListAll(w http.ResponseWriter, r *http.Request)
- func (p *Products) ListSingle(w http.ResponseWriter, r *http.Request)
- func (p *Products) MiddlewareValidateProduct(next http.Handler) http.Handler
- func (p *Products) Update(w http.ResponseWriter, r *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
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 KeyProduct ¶
type KeyProduct struct{}
KeyProduct is a key used for the Product object in the context
type Products ¶
type Products struct {
// contains filtered or unexported fields
}
Products handler for getting and updating products
func NewProducts ¶
func NewProducts(l *log.Logger, v *data.Validation, cc protos.CurrencyClient) *Products
NewProducts returns a new products handler with the given logger
func (*Products) Create ¶
func (p *Products) Create(w http.ResponseWriter, r *http.Request)
Create handles POST requests to add new products
func (*Products) Delete ¶
func (p *Products) Delete(w http.ResponseWriter, r *http.Request)
Delete handles DELETE requests and removes items from the database
func (*Products) ListAll ¶
func (p *Products) ListAll(w http.ResponseWriter, r *http.Request)
ListAll handles GET requests and returns all current products
func (*Products) ListSingle ¶
func (p *Products) ListSingle(w http.ResponseWriter, r *http.Request)
ListSingle handles GET requests
func (*Products) MiddlewareValidateProduct ¶
MiddlewareValidateProduct validates the product in the request and calls next if ok
type ValidationError ¶
type ValidationError struct {
Messages []string `json:"messages"`
}
ValidationError is a collection of validation error messages