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

When I use router.Group ,there was a redirect response #1216

Closed
fengshux opened this issue Dec 27, 2017 · 2 comments
Closed

When I use router.Group ,there was a redirect response #1216

fengshux opened this issue Dec 27, 2017 · 2 comments

Comments

@fengshux
Copy link

fengshux commented Dec 27, 2017

My code like this:

   router := gin.New()

   friend := router.Group("/friend")
    {
      friend.GET("/", controller.GetFirends)
   }

I received a redirect response with statusCode 301 , while I request the path /friend with GET method.

@delphinus
Copy link

Your router sets the handler to /friend/ path. You should use router.GET("", controller...) if you want to use /friend (w/o trailing slash).

@fengshux
Copy link
Author

fengshux commented Jan 2, 2018

Your router sets the handler to /friend/ path. You should use router.GET("", controller...) if you want to use /friend (w/o trailing slash).

It works. Thank you very much.

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