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

Panic on example #17

Open
ChechkovEugene opened this issue Oct 13, 2016 · 1 comment · May be fixed by #20
Open

Panic on example #17

ChechkovEugene opened this issue Oct 13, 2016 · 1 comment · May be fixed by #20

Comments

@ChechkovEugene
Copy link

I'm trying an example

package main

import (
  "github.com/urfave/negroni"
  "github.com/goincremental/negroni-sessions"
  "github.com/goincremental/negroni-sessions/cookiestore"
  "net/http"
)

func main() {
  n := negroni.Classic()

  store := cookiestore.New([]byte("secret123"))  
  n.Use(sessions.Sessions("my_session", store))

  mux := http.NewServeMux()
  mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
    session := sessions.GetSession(req)
    session.Set("hello", "world")
  })

  n.UseHandler(mux)
  n.Run(":3000")
}

and i have

PANIC: interface conversion: *negroni.responseWriter is not negroni.ResponseWriter: missing method Before
goroutine 5 [running]:
github.com/codegangsta/negroni.(*Recovery).ServeHTTP.func1(0x740000, 0xc4200d82c0, 0xc420019620)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/recovery.go:41 +0x150
panic(0x25e700, 0xc4200d8340)
    /usr/local/opt/go/libexec/src/runtime/panic.go:458 +0x243
github.com/goincremental/negroni-sessions.Sessions.func1(0x740000, 0xc4200d82c0, 0xc4200cc0f0, 0xc4200e2140)
    /Users/chechkoveugene/Work/Go/src/github.com/goincremental/negroni-sessions/sessions.go:92 +0x183
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0xc420019710, 0x740000, 0xc4200d82c0, 0xc4200cc0f0, 0xc4200e2140)
    /Users/chechkoveugene/Work/Go/src/github.com/urfave/negroni/negroni.go:24 +0x4e
github.com/codegangsta/negroni.middleware.ServeHTTP(0x3bfe60, 0xc420019710, 0xc4200c9640, 0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0xa7
github.com/codegangsta/negroni.(middleware).ServeHTTP-fm(0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0x60
github.com/codegangsta/negroni.(*Static).ServeHTTP(0xc420019650, 0x740000, 0xc4200d82c0, 0xc4200cc0f0, 0xc4200e2120)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/static.go:53 +0x72f
github.com/codegangsta/negroni.middleware.ServeHTTP(0x3be920, 0xc420019650, 0xc4200c9620, 0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0xa7
github.com/codegangsta/negroni.(middleware).ServeHTTP-fm(0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0x60
github.com/codegangsta/negroni.(*Logger).ServeHTTP(0xc42000d600, 0x740000, 0xc4200d82c0, 0xc4200cc0f0, 0xc4200e20c0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/logger.go:31 +0x182
github.com/codegangsta/negroni.middleware.ServeHTTP(0x3be860, 0xc42000d600, 0xc4200c9600, 0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0xa7
github.com/codegangsta/negroni.(middleware).ServeHTTP-fm(0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0x60
github.com/codegangsta/negroni.(*Recovery).ServeHTTP(0xc420019620, 0x740000, 0xc4200d82c0, 0xc4200cc0f0, 0xc4200e20a0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/recovery.go:64 +0x82
github.com/codegangsta/negroni.middleware.ServeHTTP(0x3be8e0, 0xc420019620, 0xc4200c95e0, 0x740000, 0xc4200d82c0, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:33 +0xa7
github.com/codegangsta/negroni.(*Negroni).ServeHTTP(0xc4200196b0, 0x3c2da0, 0xc4200f4000, 0xc4200cc0f0)
    /Users/chechkoveugene/Work/Go/src/github.com/codegangsta/negroni/negroni.go:73 +0xdd
net/http.serverHandler.ServeHTTP(0xc42007e200, 0x3c2da0, 0xc4200f4000, 0xc4200cc0f0)
    /usr/local/opt/go/libexec/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc42007e280, 0x3c31e0, 0xc420011a00)
    /usr/local/opt/go/libexec/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
    /usr/local/opt/go/libexec/src/net/http/server.go:2293 +0x44d
@jaden-young
Copy link
Contributor

jaden-young commented Oct 17, 2016

I was just having the same problem, but found issue 16.
Basically Go 1.7 introduced the new context package, which is used by net/http's mux and also gorilla/mux. Std lib's context doesn't play nice with gorilla/context, which negroni-sessions depends on for now.

There's good info in this issue on gorilla/context.

@felipeweb felipeweb linked a pull request Apr 27, 2017 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants