product

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package product provides HTTP handlers for product-related operations. It includes endpoints for creating, reading, updating, and deleting products.

Package product provides HTTP handlers for product-related operations. It includes endpoints for creating, reading, updating, and deleting products.

Package product provides HTTP handlers for product-related operations. It includes endpoints for creating, reading, updating, and deleting products.

Package product provides HTTP handlers for product-related operations. It includes endpoints for creating, reading, updating, and deleting products.

Package product provides HTTP handlers for product-related operations. It includes endpoints for creating, reading, updating, and deleting products.

Index

Constants

View Source
const (
	// ProductDetailPath is the path for getting product details
	ProductDetailPath = "/product/{id}"
	// CreateProductPath is the path for creating a product
	CreateProductPath = "/create-product"
	// UpdateProductPath is the path for updating a product
	UpdateProductPath = "/update-product/{id}"
	// DeleteProductPath is the path for deleting a product
	DeleteProductPath = "/product/{id}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ProductAPI

type ProductAPI struct {
	// contains filtered or unexported fields
}

func NewProductAPI

func NewProductAPI(logger *logger.Logger, prdService product.ProductServiceInterface) *ProductAPI

func (*ProductAPI) CreateProductDetail

func (p *ProductAPI) CreateProductDetail(w http.ResponseWriter, r *http.Request)

CreateProductDetail godoc @Summary Create Product example @Schemes @Description Create Product example @Tags Product @Accept json @Produce json @Param product body model.CreateProductRequest true "Product" @Success 200 {object} model.ProductDetailResponse @Failure 401 {object} model.StandardResponse @Failure 400 {object} model.StandardResponse @Failure 404 {string} string "404 page not found" @Failure 500 {object} model.StandardResponse @Router /v1/create-product [post] CreateProductDetail handles HTTP requests for creating new products. It validates the request, creates the product, and returns the result.

func (*ProductAPI) DeleteProduct

func (p *ProductAPI) DeleteProduct(w http.ResponseWriter, r *http.Request)

DeleteProduct godoc @Summary Delete Product example @Schemes @Description Delete Product example @Tags Product @Accept json @Produce json @Param id path int true "Product ID" @Success 200 {object} model.StandardResponse @Failure 401 {object} model.StandardResponse @Failure 400 {object} model.StandardResponse @Failure 404 {string} string "404 page not found" @Failure 500 {object} model.StandardResponse @Router /v1/product/{id} [DELETE] DeleteProduct handles HTTP requests for deleting products by ID. It validates the ID and removes the product from the database.

func (*ProductAPI) GetProductDetail

func (p *ProductAPI) GetProductDetail(w http.ResponseWriter, r *http.Request)

GetProductDetail godoc @Summary Get Product details example @Description Get Product details by ID @Tags Product @Accept json @Produce json @Param id path int true "Product ID" @Success 200 {object} model.StandardResponse @Failure 400 {object} model.StandardResponse @Failure 401 {object} model.StandardResponse @Failure 404 {string} string "404 page not found" @Failure 500 {object} model.StandardResponse @Router /v1/product/{id} [get] GetProductDetail handles HTTP requests for retrieving product details by ID. It validates the ID and returns the product information.

func (*ProductAPI) RegisterHandlers

func (p *ProductAPI) RegisterHandlers(router *mux.Router)

func (*ProductAPI) UpdateProductDetail

func (p *ProductAPI) UpdateProductDetail(w http.ResponseWriter, r *http.Request)

UpdateProductDetail godoc @Summary Update Product example @Description Update Product by ID @Tags Product @Accept json @Produce json @Param id path int true "Product ID" @Param product body model.UpdateProductRequest true "Product" @Success 200 {object} model.StandardResponse @Failure 400 {object} model.StandardResponse @Failure 401 {object} model.StandardResponse @Failure 404 {string} string "404 page not found" @Failure 500 {object} model.StandardResponse @Router /v1/update-product/{id} [put] UpdateProductDetail handles HTTP requests for updating existing products. It validates the request and updates the product in the database.

Directories

Path Synopsis
Package model provides data structures for product-related operations.
Package model provides data structures for product-related operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL