posts

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	List(ctx *gin.Context)
	Find(ctx *gin.Context)
	Create(ctx *gin.Context)
	Update(ctx *gin.Context)
	Delete(ctx *gin.Context)
}

Handler defines methods for posts to interact with the server.

type Posts

type Posts struct {
	*deps.Deps
}

Posts defines the handler for all posts routes.

func New

func New(d *deps.Deps) *Posts

New

Creates a new posts handler.

func (*Posts) Create

func (c *Posts) Create(ctx *gin.Context)

Create

Returns http.StatusOK if the post was created. Returns http.StatusInternalServerError if there was an error creating or formatting the post. Returns http.StatusBadRequest if the the validation failed or there was a conflict with the post.

func (*Posts) Delete

func (c *Posts) Delete(ctx *gin.Context)

Delete

Returns http.StatusOK if the post was deleted. Returns http.StatusInternalServerError if there was an error deleting the post. Returns http.StatusBadRequest if the the post wasn't found or no ID was passed.

func (*Posts) Find

func (c *Posts) Find(ctx *gin.Context)

Find

Returns http.StatusOK if the posts were obtained. Returns http.StatusBadRequest if the ID wasn't passed or failed to convert. Returns http.StatusInternalServerError if there as an error obtaining or formatting the post.

func (*Posts) List

func (c *Posts) List(ctx *gin.Context)

List

Get all posts, obtain resource param to pass to the get function.

Returns http.StatusOK if there are no posts or success. Returns http.StatusBadRequest if there was conflict or the request was invalid. Returns http.StatusInternalServerError if there was an error getting or formatting the posts.

func (*Posts) Update

func (c *Posts) Update(ctx *gin.Context)

Update

Returns http.StatusOK if the post was updated. Returns http.StatusInternalServerError if there was an error updating or formatting the post. Returns http.StatusBadRequest if the the validation failed, there was a conflict, or the post wasn't found.

Jump to

Keyboard shortcuts

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