From 45b1281a7301d0493df17c15a53794887106e610 Mon Sep 17 00:00:00 2001 From: Cameron Halter <6365055+EightB1ts@users.noreply.github.com> Date: Mon, 4 Dec 2017 11:00:12 -0500 Subject: [PATCH 1/2] Support Revel release v0.18.0 --- revel/bugsnagrevel.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revel/bugsnagrevel.go b/revel/bugsnagrevel.go index 43afa0d9..04ad1b20 100644 --- a/revel/bugsnagrevel.go +++ b/revel/bugsnagrevel.go @@ -37,7 +37,7 @@ 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 - event.RawData = append(event.RawData, controller.Request.Request) + event.RawData = append(event.RawData, controller.Request) event.Context = controller.Action event.MetaData.AddStruct("Session", controller.Session) } From c94efc7e2d52450c5ada981bfd2267a16487586a Mon Sep 17 00:00:00 2001 From: Cameron Halter <6365055+EightB1ts@users.noreply.github.com> Date: Tue, 5 Dec 2017 02:00:21 -0500 Subject: [PATCH 2/2] Semantic versioning & maintain compatibility with Revel Implements basic semantic versioning (Major/Minor changes) along with support for v0.18.0. --- revel/bugsnagrevel.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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