Skip to content

url with trailing slash /hello/xx/ match route "/hello/:name" return 200 and empty body  #12

Description

@tablecell
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions