-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Hi, when we have both /route and /route/:something. Navigating to /route/ is throwing method not allowed which is wrong.
It should either redirect to /route or show not found.
Code to reproduce:
package main
import (
"net/http"
"github.com/labstack/echo"
mw "github.com/labstack/echo/middleware"
"github.com/rs/cors"
)
func main() {
// CORS Middleware
corsMw := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
}).Handler
// Echo instance
e := echo.New()
// Middleware
e.Use(mw.Logger())
e.Use(mw.Recover())
e.Use(corsMw)
// Routes
e.Get("/stages/:stage", hello)
e.Get("/stages", hello)
// Start server
e.Run(":3001")
}
func hello(c *echo.Context) error {
return c.String(http.StatusOK, "Hello, World!\n")
}Going to /stages and /stages/hello is showing Hello, World! but going to /stages/ is showing Method Not Allowed and throwing the following in the console
ERROR|echo|Method Not Allowed
INFO|echo|::1 GET /stages/ 405 97.403µs 19