url with trailing slash /index/100/ match route "/index/:id" return 301 not 404
tablecell opened this issue · comments
tablecell commented
package main
import (
"github.com/henrylee2cn/faygo"
"time"
)
type Index struct {
}
func (i *Index) Serve(ctx *faygo.Context) error {
if ctx.CookieParam("faygoID") == "" {
ctx.SetCookie("faygoID", time.Now().String())
}
return ctx.JSON(200, i)
}
func main() {
app := faygo.New("myapp", "0.1")
app.GET("/index/:id", new(Index))
faygo.Run() //8080
}
```
$ curl http://localhost:8080/index/100/
<a href="/index/100">Moved Permanently</a>.
```
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/hello/aa", func (w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to my website!")
})
http.ListenAndServe(":80", nil)
}
```
$ curl http://localhost:8080/index/100/
404 page not found