stretchr / goweb

A lightweight RESTful web framework for Go
632 stars 61 forks source link

why "/" is generate error? #8

Closed Nipol closed 11 years ago

Nipol commented 11 years ago

func main() {

goweb.MapFunc("/", func(c *goweb.Context) {
    t, _ := template.ParseFiles("html/index.html")
    t.Execute(c.ResponseWriter, nil)
})

goweb.MapFunc("/user", func(c *goweb.Context) {
    fmt.Println(c.Request.FormValue("id"))
    fmt.Println(c.Request.FormValue("pass"))
})

goweb.ListenAndServe(":8080")

}

root page is

"Oops, something went wrong: No route found for that path"

why not working? my eye's in Red on inside every code i don't know that. help me

matryer commented 11 years ago

Have you tried "" instead of "/"? Slashes are trimmed.

Nipol commented 11 years ago

I tried not worked......I have access root / generated same error! and access '/user' generated print out index.html why not worked?...... simplify trimmed not problem. i think.

matryer commented 11 years ago

Try

goweb.Map("*"...

And put it at the END.

matryer commented 11 years ago

... or better still, get Goweb v2 from here: https://github.com/stretchrcom/goweb/tree/v2

matryer commented 11 years ago

This is fixed in Goweb 2