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 /hello/xx/ match route "/hello/:name" return 200 and empty body #12

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

Comments

@tablecell
Copy link

package main
import (
	"fmt"
	"github.com/kn9ts/frodo"
	"net/http"
)
func one(w http.ResponseWriter, r *frodo.Request) {
	fmt.Println("Hello, am the 1st middleware!")
}
func main() {
	app := frodo.New()
        app.RedirectTrailingSlash = false
	app.Get("/hello/:name", one)
	app.Serve() //3102
}

$ curl -v http://localhost:3102/hello/
HTTP/1.1 200 OK
Content-Length: 0

$ curl -v http://localhost:3102/hello/frodo/
HTTP/1.1 200 OK
Content-Length: 0

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


$ curl -v http://localhost/hello/
HTTP/1.1 404 Not Found

$ curl -v http://localhost/hello/frodo/
HTTP/1.1 404 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