categories

package
v0.0.0-...-c950848 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Routes

func Routes(r chi.Router, db *pg.DB) chi.Router

Routes consists of the route method declarations for Categories.

Types

type CategoryRequest

type CategoryRequest struct {
	*models.Category
}

CategoryRequest is a pointer to the Category model.

func (*CategoryRequest) Bind

func (c *CategoryRequest) Bind(r *http.Request) error

Bind validates the Category Request body for required fields.

type Handler

type Handler core.Handler

Handler consists of the DB connection and Routes

func (*Handler) CategoryCtx

func (cw *Handler) CategoryCtx(next http.Handler) http.Handler

CategoryCtx handler loads a category by either {categoryId} or {categorySlug}

func (*Handler) Delete

func (cw *Handler) Delete(w http.ResponseWriter, r *http.Request)

Delete handler deletes a category by the provided {categoryId}

func (*Handler) Get

func (cw *Handler) Get(w http.ResponseWriter, r *http.Request)

Get handler returns a category by the provided {categoryId}

func (*Handler) List

func (cw *Handler) List(w http.ResponseWriter, r *http.Request)

List handler returns all categories in JSON format.

func (*Handler) Store

func (cw *Handler) Store(w http.ResponseWriter, r *http.Request)

Store handler creates a new category and returns the category in JSON format.

func (*Handler) Update

func (cw *Handler) Update(w http.ResponseWriter, r *http.Request)

Update handler updates a category by the provided {categoryId}

Jump to

Keyboard shortcuts

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