echo
echo copied to clipboard
Echo#Group Bug
Description
this is not work:
e.Group("/admin",EnterAdmin)
but this works:
e.Group("/admin")
e.Use(EnterAdmin)
it`s the newes commit,this is wired,why?
Below below works for me:
package main
import (
"github.com/labstack/echo"
m "github.com/labstack/echo/middleware"
)
func main() {
e := echo.New()
g := e.Group("/group", m.Logger())
g.Use(m.Logger())
g.GET("", func(c echo.Context) error {
return c.JSON(200, "Hello, World!")
})
e.Logger.Fatal(e.Start(":1323"))
}
Please check your middleware.
Below should work. I think Group() itself provides just namespace for url, not endpoint.
package main
import (
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.Logger())
v1 := e.Group("/v1")
v1.GET("/echo", func(c echo.Context) error {
return c.String(http.StatusOK, "echo V1 API")
})
e.Logger.Fatal(e.Start(":1323"))
}
when you access to localhost:1323/v1/echo , you'll get string like echo V1 API .
thx