handlers

package
v0.0.0-...-ff4b850 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package classification of Product API

Documentation for Product API

Schemes: http
BasePath: /
Version: 1.0.0

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Package classification of Playservices API

Documentation of Playservices API

Schemes: http BasePath: /products Version: 6.0.0

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

Functions

func GetLoggerFromContext

func GetLoggerFromContext(ctx context.Context) *zap.Logger

func GetProductFromContext

func GetProductFromContext(ctx context.Context) *data.Product

func GetProductsFromContext

func GetProductsFromContext(ctx context.Context) []*data.Product

func GetRequestFromContext

func GetRequestFromContext(ctx context.Context) *http.Request

func GetResponseWriterFromContext

func GetResponseWriterFromContext(ctx context.Context) http.ResponseWriter

func InjectLogger

func InjectLogger(ctx context.Context, l *zap.Logger) context.Context

func InjectProduct

func InjectProduct(ctx context.Context, prod *data.Product) context.Context

func InjectProducts

func InjectProducts(ctx context.Context, prod []*data.Product) context.Context

func InjectRequest

func InjectRequest(ctx context.Context, r *http.Request) context.Context

func InjectResponseWriter

func InjectResponseWriter(ctx context.Context, w http.ResponseWriter) context.Context

Types

type GenericError

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

GenericError is a generic error message returned by a server

type LoggerKeyType

type LoggerKeyType string

type ProductKeyType

type ProductKeyType string

type ProductsHandler

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

Products is a http.Handler

func NewProducts

NewProducts returns a new products handler with the given logger

func (*ProductsHandler) Create

func (p *ProductsHandler) Create(w http.ResponseWriter, r *http.Request)

Create handles POST requests to add new products

func (*ProductsHandler) Delete

func (p *ProductsHandler) Delete(w http.ResponseWriter, r *http.Request)

Delete handles DELETE requests and removes items from the database

func (*ProductsHandler) ListAll

func (p *ProductsHandler) ListAll(w http.ResponseWriter, r *http.Request)

ListAll handles GET requests and returns all current products

func (*ProductsHandler) ListSingleProduct

func (p *ProductsHandler) ListSingleProduct(rw http.ResponseWriter, r *http.Request)

ListSingle handles GET requests

func (*ProductsHandler) MiddlewareValidateProduct

func (p *ProductsHandler) MiddlewareValidateProduct(next http.Handler) http.Handler

MiddlewareValidateProduct validates the product in the request and calls next if ok

func (*ProductsHandler) MigrateDocs

func (p *ProductsHandler) MigrateDocs(w http.ResponseWriter, r *http.Request)

func (*ProductsHandler) Update

func (p *ProductsHandler) Update(w http.ResponseWriter, r *http.Request)

Update handles PUT requests to update products

type RequestKeyType

type RequestKeyType string

type ResponseWriterKeyType

type ResponseWriterKeyType string

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