diff --git a/revel/bugsnagrevel.go b/revel/bugsnagrevel.go index 04ad1b20..2db0b489 100644 --- a/revel/bugsnagrevel.go +++ b/revel/bugsnagrevel.go @@ -6,7 +6,8 @@ package bugsnagrevel import ( "strings" "sync" - + "strconv" + "net/http" "github.com/bugsnag/bugsnag-go" "github.com/revel/revel" ) @@ -37,6 +38,12 @@ func middleware(event *bugsnag.Event, config *bugsnag.Configuration) error { for _, datum := range event.RawData { if controller, ok := datum.(*revel.Controller); ok { // make the request visible to the builtin HttpMiddleware + if version("0.18.0") { + event.RawData = append(event.RawData, controller.Request) + } else { + req := struct{*http.Request}{} + event.RawData = append(event.RawData, req.Request) + } event.RawData = append(event.RawData, controller.Request) event.Context = controller.Action event.MetaData.AddStruct("Session", controller.Session) @@ -68,3 +75,18 @@ func init() { }) }) } + +// Very basic semantic versioning. +// Returns true if given version matches or is above revel.Version +func version(reqVersion string) bool{ + req := strings.Split(reqVersion, ".") + cur := strings.Split(revel.Version, ".") + for i:=0;i<2;i++{ + rV,_ := strconv.Atoi(req[i]) + cV,_ := strconv.Atoi(cur[i]) + if (rV