Documentation ¶
Overview ¶
Package classification of Product API
Documentation for Product API
Schemes: http BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - application/json
swagger:meta
Package classification of Playservices API ¶
Documentation of Playservices API ¶
Schemes: http BasePath: /products Version: 6.0.0
Consumes: - application/json
Produces: -application/json swagger:meta
Index ¶
- Variables
- func GetLoggerFromContext(ctx context.Context) *zap.Logger
- func GetProductFromContext(ctx context.Context) *data.Product
- func GetProductsFromContext(ctx context.Context) []*data.Product
- func GetRequestFromContext(ctx context.Context) *http.Request
- func GetResponseWriterFromContext(ctx context.Context) http.ResponseWriter
- func InjectLogger(ctx context.Context, l *zap.Logger) context.Context
- func InjectProduct(ctx context.Context, prod *data.Product) context.Context
- func InjectProducts(ctx context.Context, prod []*data.Product) context.Context
- func InjectRequest(ctx context.Context, r *http.Request) context.Context
- func InjectResponseWriter(ctx context.Context, w http.ResponseWriter) context.Context
- type GenericError
- type LoggerKeyType
- type ProductKeyType
- type ProductsHandler
- func (p *ProductsHandler) Create(w http.ResponseWriter, r *http.Request)
- func (p *ProductsHandler) Delete(w http.ResponseWriter, r *http.Request)
- func (p *ProductsHandler) ListAll(w http.ResponseWriter, r *http.Request)
- func (p *ProductsHandler) ListSingleProduct(rw http.ResponseWriter, r *http.Request)
- func (p *ProductsHandler) MiddlewareValidateProduct(next http.Handler) http.Handler
- func (p *ProductsHandler) MigrateDocs(w http.ResponseWriter, r *http.Request)
- func (p *ProductsHandler) Update(w http.ResponseWriter, r *http.Request)
- type RequestKeyType
- type ResponseWriterKeyType
- 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 ¶
func GetResponseWriterFromContext ¶
func GetResponseWriterFromContext(ctx context.Context) http.ResponseWriter
func InjectProducts ¶
func InjectResponseWriter ¶
Types ¶
type GenericError ¶
type GenericError struct {
Message string `json:"message"`
}
GenericError is a generic error message returned by a server
type LoggerKeyType ¶
type LoggerKeyType string
type ProductKeyType ¶
type ProductKeyType string
type ProductsHandler ¶
type ProductsHandler struct {
// contains filtered or unexported fields
}
Products is a http.Handler
func NewProducts ¶
func NewProducts(l *zap.Logger, v *data.Validation, cc protos.CurrencyClient, db *data.ProductsDB) *ProductsHandler
NewProducts returns a new products handler with the given logger
func (*ProductsHandler) Create ¶
func (p *ProductsHandler) Create(w http.ResponseWriter, r *http.Request)
Create handles POST requests to add new products
func (*ProductsHandler) Delete ¶
func (p *ProductsHandler) Delete(w http.ResponseWriter, r *http.Request)
Delete handles DELETE requests and removes items from the database
func (*ProductsHandler) ListAll ¶
func (p *ProductsHandler) ListAll(w http.ResponseWriter, r *http.Request)
ListAll handles GET requests and returns all current products
func (*ProductsHandler) ListSingleProduct ¶
func (p *ProductsHandler) ListSingleProduct(rw http.ResponseWriter, r *http.Request)
ListSingle handles GET requests
func (*ProductsHandler) MiddlewareValidateProduct ¶
func (p *ProductsHandler) MiddlewareValidateProduct(next http.Handler) http.Handler
MiddlewareValidateProduct validates the product in the request and calls next if ok
func (*ProductsHandler) MigrateDocs ¶
func (p *ProductsHandler) MigrateDocs(w http.ResponseWriter, r *http.Request)
func (*ProductsHandler) Update ¶
func (p *ProductsHandler) Update(w http.ResponseWriter, r *http.Request)
Update handles PUT requests to update products
type RequestKeyType ¶
type RequestKeyType string
type ResponseWriterKeyType ¶
type ResponseWriterKeyType string
type ValidationError ¶
type ValidationError struct {
Messages []string `json:"messages"`
}
ValidationError is a collection of validation error messages