rest

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	SetHeader(header, value string) Client
	Create(rootURL, class string, obj interface{}) (string, error)
	Get(rootURL, class string, id uint, assoc []string) (string, error)
	Query(rootURL, class string, where string, values []string, orderBy []string, page int, pageSize int) (*Page, error)
	InvokeService(rootURL, class, method string, args ...interface{}) (string, error)
}

Client is client api for rest controller

func R

func R() Client

R return rest client for rest controller

type Controller

type Controller struct {
	brick.Trigger
	DB            orm.DBService     `inject:"DB"`
	ModelRegistry orm.ModelRegistry `inject:"DB"`
	// contains filtered or unexported fields
}

Controller ...

func (*Controller) Create

func (p *Controller) Create(w http.ResponseWriter, req *http.Request)

Create resource create func

func (*Controller) Get

func (p *Controller) Get(w http.ResponseWriter, req *http.Request)

Get get one obj. query params: assocations=a,b...

func (*Controller) Init

func (p *Controller) Init() error

Init ...

func (*Controller) InvokeObj

func (p *Controller) InvokeObj(w http.ResponseWriter, req *http.Request)

InvokeObj executing RPC API Method

func (*Controller) InvokeServiceFunc

func (p *Controller) InvokeServiceFunc() func(w http.ResponseWriter, req *http.Request)

InvokeServiceFunc call the func of service

func (*Controller) InvokeServiceRawMessageFunc

func (p *Controller) InvokeServiceRawMessageFunc() func(w http.ResponseWriter, req *http.Request)

InvokeServiceRawMessageFunc call the func of service with json.RawMessage

func (*Controller) List

func (p *Controller) List(w http.ResponseWriter, req *http.Request)

List query data list

func (*Controller) Remove

func (p *Controller) Remove(w http.ResponseWriter, req *http.Request)

Remove resource remove func

func (*Controller) SetContainer

func (p *Controller) SetContainer(c *brick.Container)

SetContainer ...

func (*Controller) Update

func (p *Controller) Update(w http.ResponseWriter, req *http.Request)

Update rest api update func

type OrmEvent

type OrmEvent struct {
	EventType OrmEventType `json:"eventType"`
	Class     class        `json:"class"`
	Data      interface{}  `json:"data"`
	ID        interface{}  `json:"id"` //the id of object that has been deleted. it's nil if EventType isn't ormDelete
}

OrmEvent ...

func NewOrmEvent

func NewOrmEvent(eventType OrmEventType, className class, data interface{}) *OrmEvent

NewOrmEvent return OrmEvent object

type OrmEventType

type OrmEventType int

OrmEventType ...

type Page

type Page struct {
	Data      json.RawMessage `json:"data"`
	Page      int             `json:"page"`
	PageCount int             `json:"pageCount"`
	PageSize  int             `json:"pageSize"`
}

Page rest response body

func (*Page) GetData

func (p *Page) GetData(data interface{}) error

GetData return json unmarshal data

type WatchEvent

type WatchEvent struct {
	WaitKey  int64
	OrmEvent *OrmEvent
	Error    string
}

WatchEvent ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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