func (rh *RecoveryHandler) Handle(ctx *tango.Context) { // capture render-controller error if render, ok := ctx.Action().(ITheme); ok { if err, ok := ctx.Result.(tango.AbortError); ok { render.RenderError(err.Code(), err) return } if err, ok := ctx.Result.(error); ok { ctx.WriteHeader(500) render.RenderError(ctx.Status(), err) return } } // capture abort error /* if err, ok := ctx.Result.(tango.AbortError); ok { ctx.WriteHeader(err.Code()) theme := new(ThemeRender) theme.SetTheme(nil) theme.RenderError(err.Code(), err) return }*/ // unexpected error tango.Errors()(ctx) }
func (h *TimeHandler) Handle(ctx *tango.Context) { t1 := time.Now() ctx.Next() ctx.Logger.Infof("Completed %v %v %v in %v for %v", ctx.Req().Method, ctx.Req().URL.Path, ctx.Status(), time.Since(t1), ctx.Req().RemoteAddr, ) }