rest

package module
v0.0.0-...-18af0c0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2015 License: MIT Imports: 8 Imported by: 0

README

rest

another simple rest api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RawDecode

func RawDecode(raw io.Reader, out interface{}) error

Types

type Api

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

func (*Api) Create

func (self *Api) Create(ctx IContext) []error

func (*Api) Delete

func (self *Api) Delete(ctx IContext) []error

func (*Api) DeleteAll

func (self *Api) DeleteAll(ctx IContext) []error

func (*Api) Fill

func (self *Api) Fill(ctx IContext, id string)

func (*Api) Init

func (self *Api) Init()

func (*Api) List

func (self *Api) List(ctx IContext) []error

func (*Api) Update

func (self *Api) Update(ctx IContext) []error

func (*Api) UpdateAll

func (self *Api) UpdateAll(ctx IContext) []error

func (*Api) View

func (self *Api) View(ctx IContext) []error

func (*Api) With

func (self *Api) With(ctx IContext, dataItem interface{})

type ApiWrapper

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

func NewApiWrapper

func NewApiWrapper(api IApi) *ApiWrapper

func (*ApiWrapper) Api

func (self *ApiWrapper) Api() IApi

func (*ApiWrapper) Create

func (self *ApiWrapper) Create(ctx IContext) []error

func (*ApiWrapper) Delete

func (self *ApiWrapper) Delete(ctx IContext) []error

func (*ApiWrapper) DeleteAll

func (self *ApiWrapper) DeleteAll(ctx IContext) []error

func (*ApiWrapper) Fill

func (self *ApiWrapper) Fill(ctx IContext, id string)

func (*ApiWrapper) Init

func (self *ApiWrapper) Init()

func (*ApiWrapper) List

func (self *ApiWrapper) List(ctx IContext) []error

func (*ApiWrapper) LoopWith

func (self *ApiWrapper) LoopWith(ctx IContext)

func (*ApiWrapper) Update

func (self *ApiWrapper) Update(ctx IContext) []error

func (*ApiWrapper) UpdateAll

func (self *ApiWrapper) UpdateAll(ctx IContext) []error

func (*ApiWrapper) View

func (self *ApiWrapper) View(ctx IContext) []error

func (*ApiWrapper) With

func (self *ApiWrapper) With(ctx IContext, dataItem interface{})

type Context

type Context struct {
	AutoSetUser func()
	// contains filtered or unexported fields
}

func (*Context) AddErr

func (self *Context) AddErr(errs ...error)

func (*Context) Errs

func (self *Context) Errs() []error

func (*Context) Handler

func (self *Context) Handler() *Handler

func (*Context) Params

func (self *Context) Params() *urlValues

func (*Context) Req

func (self *Context) Req() *Request

func (*Context) SetAutoSetUserFunc

func (self *Context) SetAutoSetUserFunc(fn func())

func (*Context) SetHandler

func (self *Context) SetHandler(handler *Handler)

func (*Context) SetReq

func (self *Context) SetReq(req *http.Request)

func (*Context) SetUser

func (self *Context) SetUser(u IUser)

func (*Context) Store

func (self *Context) Store() *store

func (*Context) TempData

func (self *Context) TempData() *tempData

func (*Context) User

func (self *Context) User() IUser

type Data

type Data interface{}

type Handler

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

func NewHandler

func NewHandler() *Handler

func (*Handler) Add

func (self *Handler) Add(name string, api *ApiWrapper)

func (*Handler) Api

func (self *Handler) Api(val interface{}) IApiWrapper

func (*Handler) Get

func (self *Handler) Get(apiName string) IApiWrapper

func (*Handler) Has

func (self *Handler) Has(apiName string) bool

type IApi

type IApi interface {
	Init()
	DataName() string
	With(ctx IContext, dataItem interface{})
	Fill(ctx IContext, id string)
	View(ctx IContext) []error
	List(ctx IContext) []error
	Create(ctx IContext) []error
	Update(ctx IContext) []error
	Delete(ctx IContext) []error
	UpdateAll(ctx IContext) []error
	DeleteAll(ctx IContext) []error
}

type IApiWrapper

type IApiWrapper interface {
	Init()
	Api() IApi
	LoopWith(ctx IContext)
	With(ctx IContext, dataItem interface{})
	Fill(ctx IContext, id string)
	View(ctx IContext) []error
	List(ctx IContext) []error
	Create(ctx IContext) []error
	Update(ctx IContext) []error
	Delete(ctx IContext) []error
	UpdateAll(ctx IContext) []error
	DeleteAll(ctx IContext) []error
}

type IContext

type IContext interface {
	User() IUser
	Handler() *Handler
	SetHandler(h *Handler)
	SetUser(u IUser)
	SetAutoSetUserFunc(func())
	Store() *store
	SetReq(req *http.Request)
	Req() *Request
	Params() *urlValues
	TempData() *tempData
	AddErr(...error)
	Errs() []error
}

func NewContext

func NewContext() IContext

type IUser

type IUser interface {
	Id() string
	SetId(id string)
}

type Request

type Request struct {
	*http.Request
}

func (*Request) Ip

func (self *Request) Ip() string

type User

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

func (*User) Id

func (self *User) Id() string

func (*User) SetId

func (self *User) SetId(id string)

Jump to

Keyboard shortcuts

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