Documentation
¶
Overview ¶
Package category provides HTTP handlers for category-related operations. It includes endpoints for creating, reading, updating, and deleting categories.
Package category provides HTTP handlers for category-related operations. It includes endpoints for creating, reading, updating, and deleting categories.
Package category provides HTTP handlers for category-related operations. It includes endpoints for creating, reading, updating, and deleting categories.
Package category provides HTTP handlers for category-related operations. It includes endpoints for creating, reading, updating, and deleting categories.
Package category provides HTTP handlers for category-related operations. It includes endpoints for creating, reading, updating, and deleting categories.
Index ¶
- Constants
- type CategoryAPI
- func (c *CategoryAPI) CreateCategoryDetail(w http.ResponseWriter, r *http.Request)
- func (c *CategoryAPI) DeleteCategory(w http.ResponseWriter, r *http.Request)
- func (c *CategoryAPI) GetCategoryByID(w http.ResponseWriter, r *http.Request)
- func (c *CategoryAPI) RegisterHandlers(router *mux.Router)
- func (c *CategoryAPI) UpdateCategory(w http.ResponseWriter, r *http.Request)
Constants ¶
const ( // CategoryByIDPath is the path for getting category by ID CategoryByIDPath = "/category/{id}" // CreateCategoryPath is the path for creating a category CreateCategoryPath = "/create-category" // UpdateCategoryPath is the path for updating a category UpdateCategoryPath = "/update-category/{id}" // DeleteCategoryPath is the path for deleting a category DeleteCategoryPath = "/category/{id}" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CategoryAPI ¶
type CategoryAPI struct {
// contains filtered or unexported fields
}
func NewCategoryAPI ¶
func NewCategoryAPI(logger *logger.Logger, catSrvc category.CategoryServiceInterface) *CategoryAPI
func (*CategoryAPI) CreateCategoryDetail ¶
func (c *CategoryAPI) CreateCategoryDetail(w http.ResponseWriter, r *http.Request)
CreateCategoryDetail godoc @Summary Create Category example @Schemes @Description Create Category example @Tags Category @Accept json @Produce json @Param category body model.CreateCategoryRequest true "Category" @Success 200 {object} model.CreateCategoryResponse @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-category [post] CreateCategoryDetail handles HTTP requests for creating new categories. It validates the request, creates the category, and returns the result.
func (*CategoryAPI) DeleteCategory ¶
func (c *CategoryAPI) DeleteCategory(w http.ResponseWriter, r *http.Request)
DeleteCategory godoc @Summary Delete Category example @Schemes @Description Delete Category example @Tags Category @Accept json @Produce json @Param id path int true "Category 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/category/{id} [DELETE] DeleteCategory handles HTTP requests for deleting categories by ID. It validates the ID and removes the category from the database.
func (*CategoryAPI) GetCategoryByID ¶ added in v1.3.0
func (c *CategoryAPI) GetCategoryByID(w http.ResponseWriter, r *http.Request)
GetCategoryByID godoc @Summary Get category by ID @Description Get category details by ID @Tags Category @Accept json @Produce json @Param id path int true "Category ID" @Success 200 {object} model.CategoryByIDResponse @Failure 400 {object} model.StandardResponse @Failure 404 {object} model.StandardResponse @Router /category/{id} [get]
func (*CategoryAPI) RegisterHandlers ¶
func (c *CategoryAPI) RegisterHandlers(router *mux.Router)
func (*CategoryAPI) UpdateCategory ¶
func (c *CategoryAPI) UpdateCategory(w http.ResponseWriter, r *http.Request)
UpdateCategory godoc @Summary Update Category example @Schemes @Description Update Category example @Tags Category @Accept json @Produce json @Param id path int true "Category ID" @Param category body model.UpdateCategoryRequest true "Category" @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/category/{id} [put] UpdateCategory handles HTTP requests for updating existing categories. It validates the request and updates the category in the database.