Documentation ¶
Index ¶
- func ReturnError(w http.ResponseWriter, statusCode int, err error)
- func ReturnJSON(w http.ResponseWriter, statusCode int, data interface{})
- type IHandlers
- func (p IHandlers) CreateProduct(w http.ResponseWriter, r *http.Request)
- func (p IHandlers) DeleteProduct(w http.ResponseWriter, r *http.Request)
- func (p IHandlers) GetProduct(w http.ResponseWriter, r *http.Request)
- func (p IHandlers) GetProducts(w http.ResponseWriter, r *http.Request)
- func (p IHandlers) UpdateProduct(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReturnError ¶
func ReturnError(w http.ResponseWriter, statusCode int, err error)
ReturnError throws the errors in JSON format
func ReturnJSON ¶
func ReturnJSON(w http.ResponseWriter, statusCode int, data interface{})
ReturnJSON returns a JSON response for the request
Types ¶
type IHandlers ¶
type IHandlers struct {
// contains filtered or unexported fields
}
IHandlers serves as interface for the API handlers
func NewProductHandlers ¶
NewProductHandlers creates a instance for connecting to Products table in database
func (IHandlers) CreateProduct ¶
func (p IHandlers) CreateProduct(w http.ResponseWriter, r *http.Request)
CreateProduct is the handler for creating a product
func (IHandlers) DeleteProduct ¶
func (p IHandlers) DeleteProduct(w http.ResponseWriter, r *http.Request)
DeleteProduct is the handler for deleting a product by its ID
func (IHandlers) GetProduct ¶
func (p IHandlers) GetProduct(w http.ResponseWriter, r *http.Request)
GetProduct is the handler for getting one product by its ID
func (IHandlers) GetProducts ¶
func (p IHandlers) GetProducts(w http.ResponseWriter, r *http.Request)
GetProducts is the handler for getting the list of products
func (IHandlers) UpdateProduct ¶
func (p IHandlers) UpdateProduct(w http.ResponseWriter, r *http.Request)
UpdateProduct is the handler for updating one product
Click to show internal directories.
Click to hide internal directories.