crud

package
v2.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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