VividCortex / siesta

Composable framework for writing HTTP handlers in Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic when no routes are defined

Preetam opened this issue · comments

package main

import (
    "net/http"

    "github.com/VividCortex/siesta"
)

func main() {
    service := siesta.NewService("/")
    http.ListenAndServe(":8080", service)
}

Run that, and GET http://localhost:8080/.

  ∂ [12:35:29] [tmp]: go run example.go 
2014/12/16 12:35:48 http: panic serving [::1]:60119: runtime error: invalid memory address or nil pointer dereference
goroutine 20 [running]:
net/http.func·011()
    /usr/local/go/src/pkg/net/http/server.go:1100 +0xb7
runtime.panic(0x27f820, 0x426d04)
    /usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
github.com/VividCortex/siesta.(*node).getValue(0x0, 0xc208000784, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/preetamjinka/go/src/github.com/VividCortex/siesta/tree.go:322 +0x76
github.com/VividCortex/siesta.(*Service).ServeHTTPInContext(0xc2080185f0, 0x4d08b0, 0xc20803a038, 0x4d0878, 0xc20803e0a0, 0xc208026000)
    /Users/preetamjinka/go/src/github.com/VividCortex/siesta/service.go:67 +0x22c
github.com/VividCortex/siesta.(*Service).ServeHTTP(0xc2080185f0, 0x4d0878, 0xc20803e0a0, 0xc208026000)
    /Users/preetamjinka/go/src/github.com/VividCortex/siesta/service.go:50 +0xad
net/http.serverHandler.ServeHTTP(0xc2080041e0, 0x4d0878, 0xc20803e0a0, 0xc208026000)
    /usr/local/go/src/pkg/net/http/server.go:1673 +0x19f
net/http.(*conn).serve(0xc208052200)
    /usr/local/go/src/pkg/net/http/server.go:1174 +0xa7e
created by net/http.(*Server).Serve
    /usr/local/go/src/pkg/net/http/server.go:1721 +0x313