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 trailingslah /hello/xxx/ match route /hello/:name should return 404 not 301 #245

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

Comments

@tablecell
Copy link

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

@devfeel
Copy link
Owner

devfeel commented Apr 17, 2022

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

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