Skip to content

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

Open
@tablecell

Description

@tablecell

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

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