示例#1
0
文件: wrapper.go 项目: win-t/karambie
func (this *MartiniHelper) context(rwc *karambie.ResponseWriterContext, r *http.Request) martini.Context {
	if v, ok := rwc.GetOk(contextInstance); ok {
		return v.(martini.Context)
	} else {
		c := &context{inject.New()}
		c.SetParent(this)

		c.Map(rwc)
		c.MapTo(c, (*martini.Context)(nil))
		c.MapTo(martini.NewResponseWriter(rwc), (*http.ResponseWriter)(nil))
		c.Map(r)

		rwc.Set(contextInstance, c)
		return c
	}
}
示例#2
0
func GetStack(c *karambie.ResponseWriterContext) (interface{}, []byte) {
	return c.Get(errInstance), c.Get(stackInstance).([]byte)
}