dotweb icon indicating copy to clipboard operation
dotweb copied to clipboard

url with trailingslah /hello/xxx/ match route /hello/:name should return 404 not 301

Open tablecell opened this issue 4 years ago • 1 comments

test.go

package main

import (
    "github.com/devfeel/dotweb"
)

func main() {
    dotapp := dotweb.New()
 
    dotapp.HttpServer.GET("/hello/:name", func(ctx dotweb.Context) error{
        return ctx.WriteString("hello " + ctx.GetRouterName("name"))
    })
 
    dotapp.StartServer(80)
}

$ curl http://localhost/hello/xx/ Moved Permanently.

should return 404 like net/http example.go

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/hello/xx/ 404 page not found

tablecell avatar Sep 02 '21 23:09 tablecell

I think this is the difference with "/hello/xxx/" and "/hello/:name", it's right?

devfeel avatar Apr 17 '22 01:04 devfeel