本文整理匯總了Golang中github.com/zaolab/sunnified/web.Context.ErrorCode方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.ErrorCode方法的具體用法?Golang Context.ErrorCode怎麽用?Golang Context.ErrorCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/zaolab/sunnified/web.Context
的用法示例。
在下文中一共展示了Context.ErrorCode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ServeRequestedEndPoint
//.........這裏部分代碼省略.........
w.(*SunnyResponseWriter).Status))
sunctxt.Close()
}
if r.MultipartForm != nil {
r.MultipartForm.RemoveAll()
}
}()
sunctxt = web.NewSunnyContext(w, r, this.id)
sunctxt.Event = this.ev.NewSubRouter(event.M{"sunny.context": sunctxt})
sunctxt.UPath = rep.UPath
sunctxt.PData = rep.PData
sunctxt.Ext = rep.Ext
sunctxt.MaxFileSize = this.MaxFileSize
sunctxt.ParseRequestData()
sw.ctxt = sunctxt
for n, f := range this.resources {
sunctxt.SetResource(n, f())
}
for _, midware := range this.MiddleWares {
midware.Request(sunctxt)
defer midware.Cleanup(sunctxt)
}
if router.HandleHeaders(sunctxt, rep.EndPoint, rep.Handler) {
return
}
sw.midwares = this.mwareresp
for _, midware := range this.MiddleWares {
midware.Body(sunctxt)
}
if ctrl, ok := rep.Handler.(controller.ControlHandler); ok {
ctrlmgr := ctrl.GetControlManager(sunctxt)
if ctrlmgr == nil {
goto notfound
}
sunctxt.Module = ctrlmgr.ModuleName()
sunctxt.Controller = ctrlmgr.ControllerName()
sunctxt.Action = ctrlmgr.ActionName()
if err := sunctxt.WaitRequestData(); err != nil {
setreqerror(err, w)
return
}
// TODO: Controller should not matter which is called first..
// make it a goroutine once determined sunctxt and ctrlmgr is completely thread-safe
for _, midware := range this.MiddleWares {
midware.Controller(sunctxt, ctrlmgr)
}
state, vw := ctrlmgr.PrepareAndExecute()
defer ctrlmgr.Cleanup()
if vw != nil && !sunctxt.IsRedirecting() && !sunctxt.HasError() {
setFuncMap(sunctxt, vw)
// TODO: View should not matter which is called first..
// make it a goroutine once determined sunctxt and ctrlmgr is completely thread-safe
for _, midware := range this.MiddleWares {
midware.View(sunctxt, vw)
}
if err := ctrlmgr.PublishView(); err != nil {
log.Println(err)
}
}
if sunctxt.HasError() {
this.triggerevent(sunctxt, "contexterror", map[string]interface{}{"context.error": sunctxt.AppError()})
handler.ErrorHtml(w, r, sunctxt.ErrorCode())
} else if sunctxt.IsRedirecting() {
this.triggerevent(sunctxt, "redirect", map[string]interface{}{"redirection": sunctxt.Redirection()})
} else if state != -1 && (state < 200 || state >= 300) {
handler.ErrorHtml(w, r, state)
}
} else {
if err := sunctxt.WaitRequestData(); err != nil {
setreqerror(err, w)
return
}
if h, ok := rep.Handler.(web.ContextHandler); ok {
h.ServeContextHTTP(sunctxt)
} else {
rep.Handler.ServeHTTP(w, r)
}
}
return
notfound:
handler.NotFound(w, r)
}