martini-contrib/secure — pull request #6 by attilaolah (2014-04-12 09:28:56+00:00)
Title: fix a panic on app engine

I'm trying to run the following code as an App Engine app, with `goapp serve` locally:

```go
package foo

import (
// standard go libraries
"net/http"

"github.com/go-martini/martini"
"github.com/martini-contrib/secure"
)

func init() {
m := martini.Classic()
m.Post("/", func() string {
return "Hello!"
})
m.Use(secure.Secure(secure.Options{
SSLRedirect: true,
}))
http.Handle("/", m)
}
```

But I get the following panic when I try to access the server:

```
Value not found for type martini.Context
/home/aatiis/go/src/github.com/go-martini/martini/martini.go:167 (0x503768)
(*context).run: panic(err)
/home/aatiis/go/src/github.com/go-martini/martini/martini.go:156 (0x50368b)
(*context).Next: c.run()
/home/aatiis/go/src/github.com/go-martini/martini/recovery.go:140 (0x507826)
func.004: c.Next()
/tmp/appengine/go_appengine/goroot/src/pkg/runtime/asm_amd64.s:339 (0x423bc2)
/tmp/appengine/go_appengine/goroot/src/pkg/reflect/value.go:474 (0x4f1c4b)
/tmp/appengine/go_appengine/goroot/src/pkg/reflect/value.go:345 (0x4f0d3d)
/home/aatiis/go/src/github.com/codegangsta/inject/inject.go:102 (0x5610d4)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/aatiis/go/src/github.com/go-martini/martini/martini.go:165 (0x503732)
(*context).run: _, err := c.Invoke(c.handler())
/home/aatiis/go/src/github.com/go-martini/martini/martini.go:156 (0x50368b)
(*context).Next: c.run()
/home/aatiis/go/src/github.com/go-martini/martini/logger.go:16 (0x5070c8)
func.001: c.Next()
/tmp/appengine/go_appengine/goroot/src/pkg/runtime/asm_amd64.s:340 (0x423c22)
/tmp/appengine/go_appengine/goroot/src/pkg/reflect/value.go:474 (0x4f1c4b)
/tmp/appengine/go_appengine/goroot/src/pkg/reflect/value.go:345 (0x4f0d3d)
/home/aatiis/go/src/github.com/codegangsta/inject/inject.go:102 (0x5610d4)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/aatiis/go/src/github.com/go-martini/martini/martini.go:165 (0x503732)
(*context).run: _, err := c.Invoke(c.handler())
/home/aatiis/go/src/github.com/go-martini/martini/martini.go:69 (0x502a53)
(*Martini).ServeHTTP: m.createContext(res, req).run()
/tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1496 (0x48d623)
/tmp/appengine/go_appengine/goroot/src/pkg/appengine_internal/api_dev.go:97 (0x426612)
/tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1220 (0x48c180)
/tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1597 (0x48debe)
/tmp/appengine/go_appengine/goroot/src/pkg/net/http/server.go:1167 (0x48bdd7)
/tmp/appengine/go_appengine/goroot/src/pkg/runtime/proc.c:1394 (0x4173b0)
```

This PR fixes that, but I don't fully understand how.