crud

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound occurs when item with given ID if not found
	ErrNotFound = goerrors.New("item not found")

	// ErrInvalid occurs when invalid action is requested
	ErrInvalid = goerrors.New("invalid")
)

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

App of package

func New

func New(config Config, service ItemService) *App

New creates new App from Config

func (App) Handler

func (a App) Handler() http.Handler

Handler for CRUD requests. Should be use with net/http

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config of package

func Flags

func Flags(fs *flag.FlagSet, prefix string) Config

Flags adds flags for configuring package

type Item

type Item interface {
	SetID(string)
}

Item describe item

type ItemService

type ItemService interface {
	Unmarsall([]byte) (Item, error)
	List(ctx context.Context, page, pageSize uint, sortKey string, sortAsc bool, filters map[string][]string) ([]Item, uint, error)
	Get(ctx context.Context, ID string) (Item, error)
	Create(ctx context.Context, o Item) (Item, error)
	Update(ctx context.Context, o Item) (Item, error)
	Delete(ctx context.Context, o Item) error
}

ItemService retrieves item

Jump to

Keyboard shortcuts

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