rest

package module
v0.0.0-...-9aeae76 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: MIT Imports: 9 Imported by: ? 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.

README

echo-rest

REST handlers for the Go Echo web framework.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(h Handler, g *echo.Group)

Register a given handler to an echo Group.

Types

type BoltHandler

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

BoltHandler holds the data needed for a bolt backend handler

func NewBoltHandler

func NewBoltHandler(db *bolt.DB, name []byte, instantiate func() MarshalableModel) (*BoltHandler, error)

NewBoltHandler creates a new BoltHandler instance

func (*BoltHandler) Browse

func (b *BoltHandler) Browse(c echo.Context) error

Browse the list of items in the handler bucket

func (*BoltHandler) Create

func (b *BoltHandler) Create(c echo.Context) error

Create an item in the handler bucket

func (*BoltHandler) Delete

func (b *BoltHandler) Delete(c echo.Context) error

Delete the bucket (default not allowed)

func (*BoltHandler) Modify

func (b *BoltHandler) Modify(c echo.Context) error

Modify a part of an item in the handler bucket

func (*BoltHandler) Remove

func (b *BoltHandler) Remove(c echo.Context) error

Remove an item in the handler bucket

func (*BoltHandler) Select

func (b *BoltHandler) Select(c echo.Context) error

Select an item from the handler bucket

func (*BoltHandler) Update

func (b *BoltHandler) Update(c echo.Context) error

Update an entire item in the handler bucket

type Handler

type Handler interface {
	Browse(echo.Context) error
	Create(echo.Context) error
	Delete(echo.Context) error
	Select(echo.Context) error
	Modify(echo.Context) error
	Update(echo.Context) error
	Remove(echo.Context) error
}

Handler defines the REST endpoint handlers interface

type Marshalable

type Marshalable interface {
	GetModel() Model
	SetModel(Model)
	Marshal() ([]byte, error)
	Unmarshal([]byte) error
	MarshalJSON() ([]byte, error)
	UnmarshalJSON([]byte) error
}

Marshalable defines the interface required for Model marshalling

type MarshalableModel

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

MarshalableModel is the integrated type for Model and Marshalable

func NewJSONModel

func NewJSONModel(model Model) MarshalableModel

NewJSONModel returns a new jsonMarshalable MarshalableModel

func (*MarshalableModel) Filter

func (m *MarshalableModel) Filter(v url.Values) bool

Filter delegates the call to Marshalable.Model.Filter

func (*MarshalableModel) MakeKey

func (m *MarshalableModel) MakeKey(n uint64) []byte

MakeKey delegates the call to Marshalable.Model.MakeKey

func (*MarshalableModel) Marshal

func (m *MarshalableModel) Marshal() ([]byte, error)

Marshal delegates the call to Marshalable.Marshal

func (*MarshalableModel) MarshalJSON

func (m *MarshalableModel) MarshalJSON() ([]byte, error)

MarshalJSON delegates the call to Marshalable.MarshalJSON

func (*MarshalableModel) Merge

func (m *MarshalableModel) Merge(other MarshalableModel) error

Merge delegates the call to Marshalable.Model.Merge

func (*MarshalableModel) Unmarshal

func (m *MarshalableModel) Unmarshal(data []byte) error

Unmarshal delegates the call to Marshalable.Unmarshal

func (*MarshalableModel) UnmarshalJSON

func (m *MarshalableModel) UnmarshalJSON(data []byte) error

UnmarshalJSON delegates the call to Marshalable.UnmarshalJSON

func (*MarshalableModel) Validate

func (m *MarshalableModel) Validate() error

Validate delegates the call to Marshalable.Model.Validate

type Model

type Model interface {
	Validate() error
	MakeKey(uint64) []byte
	Filter(url.Values) bool
	Merge(Model) error
}

Model defines the interface required for REST handling

Jump to

Keyboard shortcuts

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