posts

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertOrUpdateCategories

func InsertOrUpdateCategories(tx *pg.Tx, post *models.Post) error

func InsertOrUpdateTags

func InsertOrUpdateTags(tx *pg.Tx, post *models.Post) error

func Routes

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

Routes consists of the route method declarations for Posts.

Types

type Handler

type Handler core.Handler

Handler consists of the DB connection and Routes

func (*Handler) Delete

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

Delete handler deletes a post by the provided {postId}

func (*Handler) Get

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

Get handler returns a post by the provided {postId}

func (*Handler) Init

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

Init handler registers models

func (*Handler) List

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

List handler returns all posts in JSON format.

func (*Handler) PostCtx

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

PostCtx handler loads a post by either {postId} or {postSlug}

func (*Handler) Store

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

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

func (*Handler) Update

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

Update handler updates a post by the provided {postId}

type PostRequest

type PostRequest struct {
	*models.Post
}

PostRequest is a pointer to the Post model.

func (*PostRequest) Bind

func (p *PostRequest) Bind(r *http.Request) error

Bind validates the Post Request body for required fields.

Jump to

Keyboard shortcuts

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