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

HTTP panic when using static and params routers #1653

Closed
3 tasks done
andrey1s opened this issue Oct 14, 2020 · 1 comment · Fixed by #1659
Closed
3 tasks done

HTTP panic when using static and params routers #1653

andrey1s opened this issue Oct 14, 2020 · 1 comment · Fixed by #1659

Comments

@andrey1s
Copy link

andrey1s commented Oct 14, 2020

Issue Description

HTTP panic when using static and params routers

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

router not found

Actual behaviour

echo: http: panic serving [::1]:60088: runtime error: index out of range [-1]
goroutine 6 [running]:
net/http.(*conn).serve.func1(0xc0001337c0)
	/usr/local/Cellar/go/1.15.2/libexec/src/net/http/server.go:1801 +0x147
panic(0x1343e40, 0xc000016580)
	/usr/local/Cellar/go/1.15.2/libexec/src/runtime/panic.go:975 +0x3e9
github.com/labstack/echo/v4.(*Router).Find(0xc00000e940, 0xc000016560, 0x3, 0xc000016564, 0x12, 0x13d1b80, 0xc000133860)
	/Users/andrey/go/pkg/mod/github.com/labstack/echo/v4@v4.1.17/router.go:431 +0x11ca
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc00000c1e0, 0x13cdf00, 0xc0001781c0, 0xc000184000)
	/Users/andrey/go/pkg/mod/github.com/labstack/echo/v4@v4.1.17/echo.go:619 +0x12b
net/http.serverHandler.ServeHTTP(0xc000178000, 0x13cdf00, 0xc0001781c0, 0xc000184000)
	/usr/local/Cellar/go/1.15.2/libexec/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc0001337c0, 0x13ce6c0, 0xc0000786c0)
	/usr/local/Cellar/go/1.15.2/libexec/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
	/usr/local/Cellar/go/1.15.2/libexec/src/net/http/server.go:2969 +0x36c

Steps to reproduce

curl -X GET -H "Content-Type: application/json" localhost:8811/users/creates

Working code to debug

package main

import (
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

func main() {
	s := echo.New()
	s.Use(middleware.Logger())
	users := s.Group("/users")

	users.GET("/create", func(c echo.Context) error {
		return nil
	})
	users.GET("/:id/edit", func(c echo.Context) error {
		return nil
	})
	users.GET("/:id/active", func(c echo.Context) error {
		return nil
	})

	s.Start(":8811")
}

Version/commit

v4.1.17

@pafuent
Copy link
Contributor

pafuent commented Oct 25, 2020

I uploaded #1659 to fix this issue

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

Successfully merging a pull request may close this issue.

2 participants