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 tailling flash /hello/aa/ match route "/hello/:name" should return 404 like net/http #15

Open
tablecell opened this issue Sep 3, 2021 · 1 comment

Comments

@tablecell
Copy link

tablecell commented Sep 3, 2021

package main

import "github.com/yarf-framework/yarf"

type Hello struct {
	yarf.Resource
}

func (h *Hello) Get(c *yarf.Context) error {
	name := c.Param("name")

	c.Render("Hello, " + name)

	return nil
}
func main() {
	// Create a new empty YARF server
	y := yarf.New()
	hello := new(Hello)
	y.Add("/", hello)
	y.Add("/hello/:name", hello)
	y.Start(":8080")
}

$ curl http://localhost:8080/hello/xxx/
Hello, xxx

package main
import (
    "fmt"
    "net/http"
)
func main() {
    http.HandleFunc("/hello/xxx", func (w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Welcome to my website!")
    })
   http.ListenAndServe(":80", nil)
}

curl http://localhost:8080/hello/xxx/
Not found

@leonelquinteros
Copy link
Contributor

Hi @tablecell ,

The trailing slash behaviour is made on purpose here. As described in the README doc in the "Simple router" section.
The implementation code is also clear about that purpose.

That said, other than what net/http does, is there other arguments to discuss about this? I'm open to review the design.

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

2 participants