puppy

package
v0.0.0-...-cf576ff Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeInvalidInput = http.StatusUnprocessableEntity
	ErrCodeNotFound     = http.StatusNotFound
	ErrCodeInternal     = http.StatusInternalServerError
)

Error codes

Variables

View Source
var (
	//LostPuppyURL contains lost puppy service endpoint and it setup by cmd/puppy-server
	LostPuppyURL = ""
)
View Source
var SlowRequestDuration = 2 * time.Second

Functions

func LostPuppyBackend

func LostPuppyBackend() *gin.Engine

LostPuppyBackend provides information if puppy was lost

func LostPuppyReq

func LostPuppyReq(id int)

LostPuppyReq sends request to lostpuppy service

func RestBackend

func RestBackend(s Storer) *gin.Engine

RestBackend serves puppy over http

Types

type Error

type Error struct {
	Message string
	Code    int
}

Error wraps errors with code, message and error itself

func Errorf

func Errorf(code int, format string, args ...interface{}) *Error

Errorf creates a new Error with formatting

func (*Error) Error

func (e *Error) Error() string

Error returns error as a string

type Puppy

type Puppy struct {
	ID     int    `json:"id"`
	Value  int    `json:"value"`
	Breed  string `json:"breed"`
	Colour string `json:"colour"`
}

Puppy contains information about single puppy

type Storer

type Storer interface {
	ReadPuppy(ID int) (*Puppy, error)
	UpdatePuppy(ID int, puppy *Puppy) error
	CreatePuppy(puppy *Puppy) (int, error)
	DeletePuppy(ID int) error
}

Storer interface for Store implementations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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