PANIC: Value not found for type martini.Context
cdeadlock opened this issue · comments
I have a seemingly fine app with working tests when I run as
http.ListenAndServe(":4000", m)
When I try
http.ListenAndServeTLS(":8443", "cert.pem", "key.pem", m)
I get a runtime panic when triggered by a CURL command
curl -k https://localhost:8443/signup
[martini] Started GET /signup for 127.0.0.1:52108
[martini] PANIC: Value not found for type martini.Context
/usr/local/go/src/runtime/panic.go:387 (0x416928)
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/martini.go:175 (0x480816)
(*context).run: panic(err)
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/martini.go:164 (0x4806e3)
(*context).Next: c.run()
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/recovery.go:142 (0x485d09)
func.004: c.Next()
/usr/local/go/src/runtime/asm_amd64.s:402 (0x429a95)
/usr/local/go/src/reflect/value.go:419 (0x5932a5)
/usr/local/go/src/reflect/value.go:296 (0x59209c)
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/codegangsta/inject/inject.go:102 (0x5a4747)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/martini.go:173 (0x4807d1)
(*context).run: _, err := c.Invoke(c.handler())
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/martini.go:164 (0x4806e3)
(*context).Next: c.run()
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/logger.go:25 (0x4853cf)
func.001: c.Next()
/usr/local/go/src/runtime/asm_amd64.s:403 (0x429b05)
/usr/local/go/src/reflect/value.go:419 (0x5932a5)
/usr/local/go/src/reflect/value.go:296 (0x59209c)
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/codegangsta/inject/inject.go:102 (0x5a4747)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/martini.go:173 (0x4807d1)
(*context).run: _, err := c.Invoke(c.handler())
/home/deadlock/src/gosrc/src/smartbuzz/Godeps/_workspace/src/github.com/go-martini/martini/martini.go:69 (0x47f554)
(*Martini).ServeHTTP: m.createContext(res, req).run()
/usr/local/go/src/net/http/server.go:1703 (0x45c27a)
/usr/local/go/src/net/http/server.go:1204 (0x459d47)
/usr/local/go/src/runtime/asm_amd64.s:2232 (0x42bb41)
[martini] Completed 500 Internal Server Error in 496.868µs
What is different with martini when TLS is used?
Is the martini-contrib/secure required?
I have tracked it down to a graceful shutdown code I found
func (g *GracefulShutdown) Handler(c martini.Context) {
g.wg.Add(1)
c.Next()
g.wg.Done()
}
gracefulShutdown := &GracefulShutdown{Timeout: time.Duration(20) * time.Second}
m.Use(gracefulShutdown.Handler)
So there is some condition during TLS that calling c.Next() is inappropriate?
This is some kind of weird build problem on my end, if I move the graceful shutdown code into the same file it works fine.
I guess I need to figure out how godep and project paths work more thoroughly