Documentation ¶
Overview ¶
Context contains the type Uni. An instance of this type is passed to the modules when routing the control to them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Convert = basic.Convert
Functions ¶
This section is empty.
Types ¶
type Ev ¶
type Ev struct {
// contains filtered or unexported fields
}
With the help of this type it's possible for the model to not have direct access to everything (*context.Uni), but still trigger events, which in turn will result in hooks (which may need access to everything) being called. Ev is an implementation of the interface Event fround in "github.com/opesun/hypecms/interfaces"
func (*Ev) Iterate ¶
Calls all hooks subscribed to eventname, with params, feeding the output of every hook into stopfunc. Stopfunc's argument signature must match the signatures of return values of the called hooks. Stopfunc must return a boolean value. A boolean value of true stops the iteration. Iterate allows to mimic the semantics of calling all hooks one by one, with *Uni if the need it, without having access to *Uni.
func (*Ev) Trigger ¶
Trigger calls hooks subscribed to eventname, passes *Uni as a first parameter if the given hook needs it (eg *context.Uni is defined as its first parameter), and params... if they are given.
Example eventname: "content.insert" Note that, different subscriptions should not be created for subsets of functionality, eg: "content.blog.insert" (where blog is a content type) should not be used, because we build the hook function name from the access path, eg: content.insert => ContentInsert may be a static, valid hookname, but ContentBlogInsert not (a module author can't know that the type will be blog or cats ahead of time).
Filtering can be done inside ContentInsert if one module wants to act only on certain information (in the example case on certain content types).
type Uni ¶
type Uni struct { Session *mgo.Session Db *mgo.Database W http.ResponseWriter Req *http.Request P string // Path string Paths []string // Path slice, contains the url (after the domain) splitted by "/" Opt map[string]interface{} // Freshest options from database. Dat map[string]interface{} // General communication channel. Put func(...interface{}) // Just a convenience function to allow fast output to http response. Root string // Absolute path of the application. Ev *Ev Caller interfaces.Caller // contains filtered or unexported fields }
General context for the application.