Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Revel release v0.18.0 #63

Merged
merged 2 commits into from
Dec 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions revel/bugsnagrevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package bugsnagrevel
import (
"strings"
"sync"

"strconv"
"net/http"
"github.com/bugsnag/bugsnag-go"
"github.com/revel/revel"
)
Expand Down Expand Up @@ -37,7 +38,13 @@ 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)
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)
}
Expand Down Expand Up @@ -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<cV && i==0) || (rV<cV && i==1){
return true
}
}
return false
}