rest

package module
v0.0.0-...-10f06b4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Unlicense Imports: 7 Imported by: 0

README

rest

RETIRED see the new verison here https://github.com/jakecoffman/go-rest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func NewController

func NewController(restful Crud, resource Resource) *controller

func StdRoutes

func StdRoutes(group *gin.RouterGroup, rest GinRest)

Types

type Crud

type Crud interface {
	List(params url.Values) (interface{}, error)
	Create(resource interface{}) (interface{}, error)
	Get(id int) (interface{}, error)
	Update(id int, resource interface{}) (interface{}, error)
	Delete(id int) error
}

type Error

type Error struct {
	Error string `json:"error"`
}

type GinRest

type GinRest interface {
	List(*gin.Context)
	Get(*gin.Context)
	Add(*gin.Context)
	Update(*gin.Context)
	Delete(*gin.Context)
}

type Repository

type Repository interface {
	Lister(limit string) (interface{}, error)
	Getter(id int) (interface{}, error)
	Adder(resource interface{}) (sql.Result, error)
	Updater(id int, resource interface{}) (sql.Result, error)
	Deleter(id int) (sql.Result, error)
}

type Resource

type Resource interface {
	Get() Resource
}

type SqliteRepository

type SqliteRepository struct {
	Repository
}

func (SqliteRepository) Create

func (r SqliteRepository) Create(resource interface{}) (interface{}, error)

func (SqliteRepository) Delete

func (r SqliteRepository) Delete(id int) error

func (SqliteRepository) Get

func (r SqliteRepository) Get(id int) (interface{}, error)

func (SqliteRepository) List

func (r SqliteRepository) List(params url.Values) (interface{}, error)

func (SqliteRepository) Update

func (r SqliteRepository) Update(id int, resource interface{}) (interface{}, error)

Directories

Path Synopsis
example
cmd

Jump to

Keyboard shortcuts

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