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 match route Get("/test/:uid" should be 404 #92

Open
tablecell opened this issue Oct 12, 2021 · 0 comments
Open

Comments

@tablecell
Copy link

tablecell commented Oct 12, 2021

package main

import (
	"fmt"
	"github.com/gocraft/web"
	"net/http"
)

type Context struct {
	HelloCount int
}

func (c *Context) Test(rw web.ResponseWriter, req *web.Request) {
	fmt.Println(c)

	fmt.Fprint(rw, req.PathParams["uid"])
}

func main() {
	router := web.New(Context{}).
		Get("/test/:uid", (*Context).Test)
	http.ListenAndServe("localhost:3000", router)
}

curl http://localhost:3000/test/web
curl http://localhost:3000/test/web/
all return 200

int standart net/http

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

curl http://localhost:3000/test/web return 200
curl http://localhost:3000/test/web/ return 404

@tablecell tablecell changed the title url with slash match route Get("/test/:uid" should be 404 url with trailing slash match route Get("/test/:uid" should be 404 Oct 12, 2021
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