handlers

package
v0.0.0-...-1ee42d9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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

func NewProductHandlers(db *sql.DB) *IHandlers

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

Jump to

Keyboard shortcuts

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