Negroni-Example icon indicating copy to clipboard operation
Negroni-Example copied to clipboard

*negroni.responseWriterCloseNotifer is not negroni.ResponseWriter: missing method Before goroutine

Open tablecell opened this issue 4 years ago • 0 comments

package main
 
import (
	"fmt"
	"net/http"
	"os"

	"github.com/codegangsta/negroni"
	"github.com/goincremental/negroni-sessions"
	"github.com/goincremental/negroni-sessions/cookiestore"
)

func main() {
	n := negroni.Classic()
	mux := http.NewServeMux()
	store := cookiestore.New([]byte("ohhhsooosecret"))
	n.Use(sessions.Sessions("global_session_store", store))
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Hello, %s!", "negroni")
	})
	n.UseHandler(mux)
	port := os.Getenv("PORT")
	if port == "" {
		port = "3300"
	}
	n.Run(":" + port)
}

go run main.go

[negroni] listening on :3300 [negroni] PANIC: interface conversion: *negroni.responseWriterCloseNotifer is not negroni.ResponseWriter: missing method Before goroutine 7 [running]: github.com/codegangsta/negroni.(*Recovery).ServeHTTP.func1(0xac1030, 0xc000006090, 0xc00006a050, 0xc000040500) |/go/pkg/mod/github.com/codegangsta/[email protected]/recovery.go:159 +0xdb panic(0x1044b00, 0xc00003ee70) /Go/src/runtime/panic.go:965 +0x1c7 github.com/goincremental/negroni-sessions.Sessions.func1(0xac1030, 0xc000006090, 0xc000040500, 0xc00002e3c0) |/go/pkg/mod/github.com/goincremental/[email protected]/sessions.go:96 +0x1bf github.com/urfave/negroni.HandlerFunc.ServeHTTP(0xc00003ea50, 0xac1030, 0xc000006090, 0xc000040500, 0xc00002e3c0) |/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:29 +0x55 github.com/codegangsta/negroni.middleware.ServeHTTP(0x1129cc0, 0xc00003ea50, 0xc000004180, 0xac1030, 0xc000006090, 0xc000040500) |/go/pkg/mod/github.com/codegangsta/[email protected]/negroni.go:38 +0xa3 github.com/codegangsta/negroni.(*Static).ServeHTTP(0xc00003e9c0, 0xac1030, 0xc000006090, 0xc000040500, 0xc00002e360) |/go/pkg/mod/github.com/codegangsta/[email protected]/static.go:53 +0x757 github.com/codegangsta/negroni.middleware.ServeHTTP(0x1129300, 0xc00003e9c0, 0xc000004168, 0xac1030, 0xc000006090, 0xc000040500) |/go/pkg/mod/github.com/codegangsta/[email protected]/negroni.go:38 +0xa3 github.com/codegangsta/negroni.(*Logger).ServeHTTP(0xc00003e7e0, 0xac1030, 0xc000006090, 0xc000040500, 0xc00002e340) |/go/pkg/mod/github.com/codegangsta/[email protected]/logger.go:62 +0x99 github.com/codegangsta/negroni.middleware.ServeHTTP(0x11292a0, 0xc00003e7e0, 0xc000004150, 0xac1030, 0xc000006090, 0xc000040500) |/go/pkg/mod/github.com/codegangsta/[email protected]/negroni.go:38 +0xa3 github.com/codegangsta/negroni.(*Recovery).ServeHTTP(0xc00006a050, 0xac1030, 0xc000006090, 0xc000040500, 0xc00002e320) |/go/pkg/mod/github.com/codegangsta/[email protected]/recovery.go:193 +0x93 github.com/codegangsta/negroni.middleware.ServeHTTP(0x11292e0, 0xc00006a050, 0xc000004138, 0xac1030, 0xc000006090, 0xc000040500) |/go/pkg/mod/github.com/codegangsta/[email protected]/negroni.go:38 +0xa3 github.com/codegangsta/negroni.(*Negroni).ServeHTTP(0xc00003ea20, 0x112f2d0, 0xc0000700e0, 0xc000040500) |/go/pkg/mod/github.com/codegangsta/[email protected]/negroni.go:96 +0xf7 net/http.serverHandler.ServeHTTP(0xc000070000, 0x112f2d0, 0xc0000700e0, 0xc000040500) /Go/src/net/http/server.go:2887 +0xaa net/http.(*conn).serve(0xc0000565a0, 0x112fd80, 0xc00003a400) /Go/src/net/http/server.go:1952 +0x8cd created by net/http.(*Server).Serve /Go/src/net/http/server.go:3013 +0x3b8

tablecell avatar Aug 17 '21 11:08 tablecell