apiserver

package module
v0.0.0-...-3a4e11d Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseID

func ParseID(val interface{}) uint

func ParseString

func ParseString(val interface{}) string

func ParseTime

func ParseTime(val interface{}) *time.Time

Types

type ApiResponse

type ApiResponse struct {
	jresp.JResp
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse() *ApiResponse

func (*ApiResponse) SetErrorCode

func (a *ApiResponse) SetErrorCode(errorCode int)

type BaseAction

type BaseAction struct {
	Handle func(r *BaseRequest)
	Route  string
	Method string
}

func NewAction

func NewAction(method string, handle func(r *BaseRequest), route string) *BaseAction

func (*BaseAction) FullRoute

func (action *BaseAction) FullRoute(controller BaseControllerI, single bool) string

type BaseController

type BaseController struct {
	ModelFn         func() interface{}
	SpecializeRowFn func(rawRow interface{}, data map[string]interface{}) interface{}
	// contains filtered or unexported fields
}

func NewController

func NewController(orm *orm.Orm, name string) BaseController

func (*BaseController) CustomActions

func (controller *BaseController) CustomActions() []*BaseAction

func (*BaseController) Delete

func (controller *BaseController) Delete(r *BaseRequest)

func (*BaseController) Get

func (controller *BaseController) Get(r *BaseRequest)

func (*BaseController) GetEditableFields

func (controller *BaseController) GetEditableFields() []string

func (*BaseController) GetEntityParams

func (controller *BaseController) GetEntityParams(request *BaseRequest) map[string]interface{}

Get parameters (lower case key => value map)

func (*BaseController) GetList

func (controller *BaseController) GetList(request *BaseRequest) interface{}

func (*BaseController) GetSingle

func (controller *BaseController) GetSingle(request *BaseRequest) interface{}

func (*BaseController) GetWhere

func (controller *BaseController) GetWhere(request *BaseRequest) *Where

func (*BaseController) Model

func (controller *BaseController) Model() interface{}

func (*BaseController) Name

func (controller *BaseController) Name() string

func (*BaseController) Orm

func (controller *BaseController) Orm() *orm.Orm

func (*BaseController) Post

func (controller *BaseController) Post(r *BaseRequest)

func (*BaseController) Put

func (controller *BaseController) Put(r *BaseRequest)

func (*BaseController) RegisterAction

func (controller *BaseController) RegisterAction(action *BaseAction)

func (*BaseController) SpecializeRow

func (controller *BaseController) SpecializeRow(rawRow interface{}, data map[string]interface{}) interface{}

type BaseControllerI

type BaseControllerI interface {
	Name() string
	CustomActions() []*BaseAction
	Orm() *orm.Orm
	InitController()
	Model() interface{}
}

type BaseHandle

type BaseHandle func(*BaseRequest)

type BaseRequest

type BaseRequest struct {
	Response http.ResponseWriter
	Request  *http.Request
	Params   httprouter.Params
	// contains filtered or unexported fields
}

func (*BaseRequest) Body

func (b *BaseRequest) Body() []byte

func (*BaseRequest) GetFilterQuery

func (request *BaseRequest) GetFilterQuery() interface{}

func (*BaseRequest) GetFilterVars

func (request *BaseRequest) GetFilterVars() []interface{}

func (*BaseRequest) GetID

func (request *BaseRequest) GetID() string

func (*BaseRequest) GetParam

func (request *BaseRequest) GetParam(key string) string

func (*BaseRequest) SetError

func (request *BaseRequest) SetError(value interface{})

Set response error

func (*BaseRequest) SetErrorCode

func (request *BaseRequest) SetErrorCode(errorCode int)

func (*BaseRequest) SetResponseBytes

func (request *BaseRequest) SetResponseBytes(b []byte)

func (*BaseRequest) SetValue

func (request *BaseRequest) SetValue(key string, value interface{})

Set response value

type Opts

type Opts struct {
	AccessControlAllowOrigin string
}

type Router

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

func New

func New(listenConf string) *Router

func (*Router) DELETE

func (this *Router) DELETE(path string, handle BaseHandle)

func (*Router) GET

func (this *Router) GET(path string, handle BaseHandle)

func (*Router) Listen

func (this *Router) Listen(fork bool)

func (*Router) Opts

func (r *Router) Opts() *Opts

func (*Router) POST

func (this *Router) POST(path string, handle BaseHandle)

func (*Router) PUT

func (this *Router) PUT(path string, handle BaseHandle)

func (*Router) RegisterController

func (this *Router) RegisterController(controller BaseControllerI)

func (*Router) Router

func (r *Router) Router() *httprouter.Router

func (*Router) ServeFiles

func (this *Router) ServeFiles(path string, filesDir string)

func (*Router) SetOpts

func (r *Router) SetOpts(opts *Opts)

type Where

type Where struct {
	Query string
	Vars  []interface{}
}

Jump to

Keyboard shortcuts

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