handlers

package
v0.0.0-...-722a0d2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package classification Product API.

the purpose of this application is to provide an application that is using plain go code to define an API

This should demonstrate all the possible comment annotations that are available to turn go code into a fully compliant swagger 2.0 spec

Documentation for Product API

Schemes: http
Host: localhost
BasePath: /
Version: 0.0.1

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidProductPath = fmt.Errorf("Invalid Path, path should be /products/[id]")

ErrInvalidProductPath is an error message when the product path is not valid reserved for 404 ?

Functions

This section is empty.

Types

type GenericError

type GenericError struct {
	Message string `json:"message"`
}

GenericError is a generic error message returned by a server

type KeyProduct

type KeyProduct struct{}

KeyProduct is a key of product used in request context

type Products

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

Products is a handler for getting and updating products

func NewProductHandler

func NewProductHandler(l hclog.Logger, v *data.Validation, pdb *data.ProductsDB) *Products

NewProductHandler creates a new Products handler

func (*Products) AddProduct

func (p *Products) AddProduct(resp http.ResponseWriter, req *http.Request)

AddProduct is a handler for creating a product

func (*Products) DeleteProduct

func (p *Products) DeleteProduct(resp http.ResponseWriter, req *http.Request)

DeleteProduct is a handler to delete a product

func (*Products) GetProductByID

func (p *Products) GetProductByID(resp http.ResponseWriter, req *http.Request)

GetProductByID is a handler that return a product

func (*Products) GetProductList

func (p *Products) GetProductList(resp http.ResponseWriter, req *http.Request)

GetProductList is a handler that return list of products

func (*Products) MiddlewareValidation

func (p *Products) MiddlewareValidation(next http.Handler) http.Handler

MiddlewareValidation is a middleware handler for product validation before going to the next handler

func (*Products) UpdateProduct

func (p *Products) UpdateProduct(resp http.ResponseWriter, req *http.Request)

UpdateProduct is a handler for updating a product

type ValidationError

type ValidationError struct {
	Messages []string `json:"messages"`
}

ValidationError is a collection of validation error messages

Jump to

Keyboard shortcuts

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