helpers

package
v0.0.0-...-d57945e Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrBadRequest

func ErrBadRequest(err error) render.Renderer

ErrBadRequest returns a 400 status code response.

func ErrConflict

func ErrConflict(err error) render.Renderer

ErrConflict returns a 409 status code response.

func ErrNotFound

func ErrNotFound(resource string, key string) render.Renderer

ErrNotFound returns a 404 status code response.

func ErrUnauthorized

func ErrUnauthorized(err error) render.Renderer

ErrUnauthorized returns a 401 status code response.

func RandomString

func RandomString(length int) string

RandomString generates random string of given length

Types

type BaseModel

type BaseModel struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

BaseModel contains common columns for all tables.

func (*BaseModel) BeforeCreate

func (base *BaseModel) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
	Status  int    `json:"status"`
}

ErrorResponse is the standard ContracterAPI error format

func (*ErrorResponse) Render

Render sets the error status code.

Jump to

Keyboard shortcuts

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