forked from julienschmidt/httprouter
-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Description
Run this hello world snippet
package main
import (
"fmt"
"log"
"github.com/buaazp/fasthttprouter"
"github.com/valyala/fasthttp"
)
func Hello(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "hello, %s!\n", ctx.UserValue("name"))
}
func main() {
router := fasthttprouter.New()
router.GET("/hello/:name", Hello)
log.Fatal(fasthttp.ListenAndServe(":8080", router.Handler))
}
Send a HEAD request
$ curl -I http://localhost:8080/hello/test 47ms
curl: (52) Empty reply from server
Results in:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x482962]
goroutine 34 [running]:
panic(0x634b40, 0xc42000c100)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/valyala/fasthttp.(*RequestCtx).SetUserValue(0x0, 0x67ee99, 0x4, 0x621d40, 0xc4201280d0)
/home/kailash/code/go/src/github.com/valyala/fasthttp/server.go:461 +0x22
github.com/buaazp/fasthttprouter.(*node).getValue(0xc420018780, 0xc4201280c7, 0x4, 0x0, 0xc4201182f8, 0xfe5)
/home/kailash/code/go/src/github.com/buaazp/fasthttprouter/tree.go:364 +0x1c7
github.com/buaazp/fasthttprouter.(*Router).allowed(0xc420013200, 0xc4201280c0, 0xb, 0xc42003ac98, 0x4, 0x4, 0x59)
/home/kailash/code/go/src/github.com/buaazp/fasthttprouter/router.go:273 +0x13d
github.com/buaazp/fasthttprouter.(*Router).Handler(0xc420013200, 0xc420138000)
/home/kailash/code/go/src/github.com/buaazp/fasthttprouter/router.go:353 +0x23e
github.com/buaazp/fasthttprouter.(*Router).Handler-fm(0xc420138000)
/home/kailash/Desktop/fast.go:19 +0x34
github.com/valyala/fasthttp.(*Server).serveConn(0xc4200983c0, 0x794040, 0xc420132000, 0x1, 0x101)
/home/kailash/code/go/src/github.com/valyala/fasthttp/server.go:1536 +0x573
github.com/valyala/fasthttp.(*Server).(github.com/valyala/fasthttp.serveConn)-fm(0x794040, 0xc420132000, 0xc420120758, 0x1)
/home/kailash/code/go/src/github.com/valyala/fasthttp/server.go:1250 +0x3e
github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc420092480, 0xc42012a100)
/home/kailash/code/go/src/github.com/valyala/fasthttp/workerpool.go:210 +0xde
github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc420092480, 0xc42012a100, 0x616480, 0xc42012a100)
/home/kailash/code/go/src/github.com/valyala/fasthttp/workerpool.go:182 +0x35
created by github.com/valyala/fasthttp.(*workerPool).getCh
/home/kailash/code/go/src/github.com/valyala/fasthttp/workerpool.go:184 +0x111
exit status 2
Metadata
Metadata
Assignees
Labels
No labels