controller

package
v0.0.0-...-7690095 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatatypeStringSuffix   = "_String"
	DatatypeIntSuffix      = "_Int"
	DatatypeInt64Suffix    = "_Int64"
	DatatypeFloatSuffix    = "_Float"
	DatatypeFloat64Suffix  = "_Float64"
	DatatypeEmailSuffix    = "_Email"
	DatatypeURLSuffix      = "_Url"
	DatatypeDateSuffix     = "_Date"
	DatatypeTimeSuffix     = "_Time"
	DatatypeDateTimeSuffix = "_Datetime"
	DatatypeBoolSuffix     = "_Bool"

	FormValueTypeTagName = "value.type"
	FormValueTypeLprefix = "form_"
)
View Source
const (
	SconConstructName = "Construct_"
	SconDestructName  = "Destruct_"
)
View Source
const StructValueFeedTag = "sunnified.feed"
View Source
const StructValueResTag = "sunnified.res"

Variables

View Source
var ErrControllerNotFound = errors.New("controller not found")
View Source
var ErrParseStruct = errors.New("Sunnified Parser error")
View Source
var ErrUnexecuted = errors.New("controller has not been executed")
View Source
var ErrUnprepared = errors.New("controller has not been prep'ed")

Functions

func AddController

func AddController(cinterface interface{}) (string, string)

func AddModule

func AddModule(alias string, modname string)

func HasController

func HasController(mod, con string) (exists bool)

func HasModule

func HasModule(mod string) bool

func Module

func Module(mod string) (m map[string]*Meta)

Types

type ActionMap

type ActionMap map[string]map[ReqMethod]*ActionMeta

func (ActionMap) Add

func (a ActionMap) Add(name string, am *ActionMeta)

func (ActionMap) Count

func (a ActionMap) Count() int

func (ActionMap) Delete

func (a ActionMap) Delete(name string)

func (ActionMap) Get

func (a ActionMap) Get(name string, reqtype ReqMethod) *ActionMeta

func (ActionMap) GetReqMeth

func (a ActionMap) GetReqMeth(name string) (rm ReqMethod)

func (ActionMap) GetReqMethList

func (a ActionMap) GetReqMethList(name string) (rml []string)

func (ActionMap) HasAction

func (a ActionMap) HasAction(name string) bool

func (ActionMap) Remove

func (a ActionMap) Remove(name string, reqtype ReqMethod)

type ActionMeta

type ActionMeta struct {
	ResultStyle
	// contains filtered or unexported fields
}

func (*ActionMeta) Args

func (am *ActionMeta) Args() []*ArgMeta

func (*ActionMeta) Name

func (am *ActionMeta) Name() string

func (*ActionMeta) RMeth

func (am *ActionMeta) RMeth() reflect.Method

func (*ActionMeta) ReqMeth

func (am *ActionMeta) ReqMeth() ReqMethod

type ArgMeta

type ArgMeta struct {
	DataMeta
}

type ControlHandler

type ControlHandler interface {
	GetControlManager(*web.Context) *ControlManager
}

type ControlManager

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

func NewControlManager

func NewControlManager(context *web.Context, cm *Meta, action string) *ControlManager

func (*ControlManager) ActionMeta

func (c *ControlManager) ActionMeta() *ActionMeta

func (*ControlManager) ActionName

func (c *ControlManager) ActionName() string

func (*ControlManager) AvailableMethods

func (c *ControlManager) AvailableMethods() ReqMethod

func (*ControlManager) AvailableMethodsList

func (c *ControlManager) AvailableMethodsList() []string

func (*ControlManager) Cleanup

func (c *ControlManager) Cleanup()

func (*ControlManager) Context

func (c *ControlManager) Context() *web.Context

func (*ControlManager) Controller

func (c *ControlManager) Controller() reflect.Value

func (*ControlManager) ControllerMeta

func (c *ControlManager) ControllerMeta() *Meta

func (*ControlManager) ControllerName

func (c *ControlManager) ControllerName() string

func (*ControlManager) Execute

func (c *ControlManager) Execute() (state int, vw mvc.View)

func (*ControlManager) IsExecuted

func (c *ControlManager) IsExecuted() bool

func (*ControlManager) IsPrepared

func (c *ControlManager) IsPrepared() bool

func (*ControlManager) ModuleName

func (c *ControlManager) ModuleName() string

func (*ControlManager) MvcMeta

func (c *ControlManager) MvcMeta() mvc.Meta

func (*ControlManager) Prepare

func (c *ControlManager) Prepare() error

func (*ControlManager) PrepareAndExecute

func (c *ControlManager) PrepareAndExecute() (state int, vw mvc.View)

func (*ControlManager) PublishView

func (c *ControlManager) PublishView() (err error)

func (*ControlManager) SetAction

func (c *ControlManager) SetAction(action string) (ok bool)

func (*ControlManager) SetControllerMeta

func (c *ControlManager) SetControllerMeta(cm *Meta) (ok bool)

func (*ControlManager) SetState

func (c *ControlManager) SetState(state int)

func (*ControlManager) State

func (c *ControlManager) State() int

func (*ControlManager) View

func (c *ControlManager) View() mvc.View

type DataMeta

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

func (*DataMeta) Fields

func (dm *DataMeta) Fields() []*FieldMeta

func (*DataMeta) LName

func (dm *DataMeta) LName() string

func (*DataMeta) Name

func (dm *DataMeta) Name() string

func (*DataMeta) RType

func (dm *DataMeta) RType() reflect.Type

func (*DataMeta) T

func (dm *DataMeta) T() DataType

type DataType

type DataType int
const (
	DatatypeWebContext DataType = 1 + iota
	DatatypeRequest
	DatatypeResponseWriter
	DatatypeUpath
	DatatypeUpathSlice
	DatatypePdata
	DatatypePdataMap
	DatatypeStruct
	DatatypeString
	DatatypeInt
	DatatypeInt64
	DatatypeFloat
	DatatypeFloat64
	DatatypeEmail
	DatatypeURL
	DatatypeDate
	DatatypeTime
	DatatypeDateTime
	DatatypeBool
	DatatypeEmbedded
)

type FieldMeta

type FieldMeta struct {
	DataMeta
	// contains filtered or unexported fields
}

func (*FieldMeta) Anonymous

func (fm *FieldMeta) Anonymous() bool

func (*FieldMeta) Rexexp

func (fm *FieldMeta) Rexexp() *regexp.Regexp

func (*FieldMeta) Tag

func (fm *FieldMeta) Tag() reflect.StructTag

type Group

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

func GetDefaultControllerGroup

func GetDefaultControllerGroup() *Group

func NewControllerGroup

func NewControllerGroup() *Group

func (*Group) AddController

func (cg *Group) AddController(cinterface interface{}) (string, string)

func (*Group) AddModule

func (cg *Group) AddModule(alias string, modname string)

func (*Group) Controller

func (cg *Group) Controller(mod, con string) (c *Meta)

func (*Group) HasController

func (cg *Group) HasController(mod, con string) (exists bool)

func (*Group) HasModule

func (cg *Group) HasModule(mod string) bool

func (*Group) Module

func (cg *Group) Module(mod string) (m map[string]*Meta)

type Meta

type Meta struct {
	ResultStyle
	// contains filtered or unexported fields
}

func Controller

func Controller(mod, con string) *Meta

func MakeControllerMeta

func MakeControllerMeta(cinterface interface{}) (cm *Meta, ctrlname, mod, modfull string)

func (*Meta) Action

func (cm *Meta) Action(name string, reqtype ReqMethod) *ActionMeta

func (Meta) ActionAvailableMethods

func (cm Meta) ActionAvailableMethods(name string) ReqMethod

func (Meta) ActionAvailableMethodsList

func (cm Meta) ActionAvailableMethodsList(name string) []string

func (Meta) ActionFromRequest

func (cm Meta) ActionFromRequest(name string, ctxt *web.Context) *ActionMeta

func (*Meta) Args

func (cm *Meta) Args() []*ArgMeta

func (*Meta) Fields

func (cm *Meta) Fields() []*FieldMeta

func (*Meta) HasAction

func (cm *Meta) HasAction(name string) bool

func (*Meta) HasActionMethod

func (cm *Meta) HasActionMethod(name string, reqtype ReqMethod) bool

func (*Meta) Meths

func (cm *Meta) Meths() ActionMap

func (*Meta) Module

func (cm *Meta) Module() string

func (*Meta) Name

func (cm *Meta) Name() string

func (*Meta) New

func (cm *Meta) New() reflect.Value

func (*Meta) RType

func (cm *Meta) RType() reflect.Type

func (*Meta) ReqMeth

func (cm *Meta) ReqMeth() ReqMethod

func (*Meta) T

func (cm *Meta) T() Type

type ReqMethod

type ReqMethod uint16
const (
	// the first four must be get, post, put and delete (the order is less impt)
	// since ActionMap.Add() depends on it to work correctly
	ReqMethodGet ReqMethod = 1 << iota
	ReqMethodPost
	ReqMethodPut
	ReqMethodDelete
	ReqMethodPatch
	ReqMethodOptions
	ReqMethodHead

	ReqMethodCommon ReqMethod = 15  //1 | 2 | 4 | 8
	ReqMethodAll    ReqMethod = 127 //1 | 2 | 4 | 8 | 16 | 32 | 64
)

func GetReqMethod

func GetReqMethod(r *http.Request) ReqMethod

func GetXReqMethod

func GetXReqMethod(ctxt *web.Context) ReqMethod

type ResultStyle

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

func (ResultStyle) IsNil

func (rs ResultStyle) IsNil() bool

func (ResultStyle) MapSI

func (rs ResultStyle) MapSI() bool

func (ResultStyle) Status

func (rs ResultStyle) Status() bool

func (ResultStyle) View

func (rs ResultStyle) View() bool

func (ResultStyle) Vmap

func (rs ResultStyle) Vmap() bool

type StructValueFeeder

type StructValueFeeder interface {
	FeedStructValue(*web.Context, *FieldMeta, reflect.Value) (reflect.Value, error)
}

type Type

type Type int
const (
	ContypeFunc Type
	ContypeStruct
	ContypeConstructor
	ContypeScontroller
)

type WebsocketChat

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

func NewWebSocketChat

func NewWebSocketChat() *WebsocketChat

func (*WebsocketChat) AddChannel

func (wc *WebsocketChat) AddChannel(channel string)

func (*WebsocketChat) AddClient

func (wc *WebsocketChat) AddClient(channel, uid string, context *web.Context)

func (*WebsocketChat) Broadcast

func (wc *WebsocketChat) Broadcast(channel string, msgT int, msg []byte)

func (*WebsocketChat) BroadcastJSON

func (wc *WebsocketChat) BroadcastJSON(channel string, msg interface{})

func (*WebsocketChat) Client

func (wc *WebsocketChat) Client(channel, uid string) map[*web.Context]*websocket.Conn

func (*WebsocketChat) MessageClient

func (wc *WebsocketChat) MessageClient(channel, uid string, msgT int, msg []byte) bool

func (*WebsocketChat) MessageJSONClient

func (wc *WebsocketChat) MessageJSONClient(channel, uid string, msg interface{}) bool

func (*WebsocketChat) RemoveClient

func (wc *WebsocketChat) RemoveClient(channel, uid string, context *web.Context)

Jump to

Keyboard shortcuts

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