// Wrapper is a Revel middleware to wrap handler execution and post to a // Defer Panic dashboard func Wrapper(dps *deferstats.Client) func(c *revel.Controller, fc []revel.Filter) { return func(c *revel.Controller, fc []revel.Filter) { startTime, tracer, headers := dps.BeforeRequest(c.Response.Out, c.Request.Request) defer func() { if err := recover(); err != nil { dps.BaseClient.Prep(err, tracer.SpanId) dps.AfterRequest(startTime, tracer, c.Request.Request, headers, 500, true) errorMsg := fmt.Sprintf("%v", err) deferstats.WritePanicResponse(c.Response.Out, c.Request.Request, errorMsg) } }() c.Response.Out = tracer fc[0](c, fc[1:]) dps.AfterRequest(startTime, tracer, c.Request.Request, headers, tracer.Status(), false) } }
// Wrapper is a Martini middleware to wrap handler execution and post to a // Defer Panic dashboard func Wrapper(dps *deferstats.Client) martini.Handler { return func(w http.ResponseWriter, r *http.Request, c martini.Context) { startTime, tracer, headers := dps.BeforeRequest(w, r) defer func() { if err := recover(); err != nil { dps.BaseClient.Prep(err, tracer.SpanId) dps.AfterRequest(startTime, tracer, r, headers, 500, true) errorMsg := fmt.Sprintf("%v", err) deferstats.WritePanicResponse(w, r, errorMsg) } }() c.MapTo(tracer, (*http.ResponseWriter)(nil)) c.Next() dps.AfterRequest(startTime, tracer, r, headers, tracer.Status(), false) } }
// Wrapper is a Echo middleware to wrap handler execution and post to a // Defer Panic dashboard func Wrapper(dps *deferstats.Client) echo.MiddlewareFunc { return func(h echo.HandlerFunc) echo.HandlerFunc { return func(c *echo.Context) error { startTime, tracer, headers := dps.BeforeRequest(c.Response().Writer(), c.Request()) defer func() { if err := recover(); err != nil { dps.BaseClient.Prep(err, tracer.SpanId) dps.AfterRequest(startTime, tracer, c.Request(), headers, 500, true) errorMsg := fmt.Sprintf("%v", err) deferstats.WritePanicResponse(c.Response().Writer(), c.Request(), errorMsg) } }() c.Response().SetWriter(tracer) if err := h(c); err != nil { c.Error(err) } dps.AfterRequest(startTime, tracer, c.Request(), headers, tracer.Status(), false) return nil } } }