handlers

package
v0.0.0-...-b2df2c4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindValid

func BindValid(c *gin.Context, vm interface{}) bool

BindValid binds the request's body to a vm and then validates the vm through govalidator.

func ConnMongoDB

func ConnMongoDB() (*mgo.Session, *mgo.Database, error)

func GetPosts

func GetPosts(c *gin.Context)

func GetPostsTitleUrl

func GetPostsTitleUrl(c *gin.Context)

func PostPosts

func PostPosts(c *gin.Context)

Types

type Error

type Error struct {
	Errors []interface{} `json:"errors"`
}

Error is a general purpose error view model.

func NewError

func NewError(errs ...interface{}) *Error

NewError helps create an Error with multiple error values without the need to manually declare a []interface{} for the Errors field.

func ValidationErrors

func ValidationErrors(err error) *Error

ValidationErrors receives a govalidator error and properly formats it into a viewmodel.Error

type Post

type Post struct {
	Title   string `json:"title" valid:"required"`
	Content string `json:"content" valid:"required"`
}

Jump to

Keyboard shortcuts

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