rest

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOption = errors.New("Must set NewModel when use PostFunc/PutFunc")
)

error(s)

View Source
var ErrResponse = &Response{
	Code: -1,
	Msg:  "FAIL",
}

ErrResponse Common

Functions

func New

func New(o *Option) (r *router.Router)

New RESTful Router

Types

type Option

type Option struct {
	Root        *router.Router
	UseNotFound bool
	NewModel    func() interface{}

	// Optional
	DefaultPageSize int
	Path            string
	GetFunc         func(id string) interface{}
	ListFunc        func(page, size int) interface{}
	PostFunc        func(interface{}) error
	PutFunc         func(interface{}) error
	DeleteFunc      func(id string) error
}

Option of RESTful Middleware

type Response

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

Response Common

Jump to

Keyboard shortcuts

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