Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url with trailing slash /index/100/ match route "/index/:id" return 301 not 404 #46

Open
tablecell opened this issue Sep 3, 2021 · 0 comments

Comments

@tablecell
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant