crud

package
v3.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServiceIsRequired occurs when underlying service is not provided
	ErrServiceIsRequired = errors.New("service is required")

	// ErrNotFound occurs when item is not found
	ErrNotFound = errors.New("not found")

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

	// ErrUnauthorized occurs when authentication not provided
	ErrUnauthorized = errors.New("authentication required")

	// ErrForbidden occurs when action is forbidden
	ErrForbidden = errors.New("forbidden")

	// ErrInternal occurs when unhandled behavior occurs
	ErrInternal = errors.New("internal server error")
)

Functions

func GetConfiguredFlags added in v3.13.0

func GetConfiguredFlags(path, name string) func(*flag.FlagSet, string) Config

GetConfiguredFlags adds flags for configuring package

Types

type App

type App interface {
	Handler() http.Handler
	Swagger() (swagger.Configuration, error)
}

App of package

func New

func New(config Config, service Service) (App, error)

New creates new App from Config

type Config

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

Config of package

type Error added in v3.5.0

type Error struct {
	Field string `json:"field"`
	Label string `json:"label"`
}

Error describes a crud error

func NewError added in v3.5.0

func NewError(field, label string) Error

NewError creates a new error

func (Error) Error added in v3.14.0

func (e Error) Error() string

Error format error to string

type Service added in v3.4.0

type Service interface {
	Unmarshal(data []byte, contentType string) (interface{}, error)
	Check(ctx context.Context, old, new interface{}) []Error
	List(ctx context.Context, page, pageSize uint, sortKey string, sortDesc bool, filters map[string][]string) ([]interface{}, uint, error)
	Get(ctx context.Context, ID uint64) (interface{}, error)
	Create(ctx context.Context, o interface{}) (interface{}, error)
	Update(ctx context.Context, o interface{}) (interface{}, error)
	Delete(ctx context.Context, o interface{}) error
}

Service retrieves item

Jump to

Keyboard shortcuts

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