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

wildcard segment ':slug' conflicts with existing children in path '/:slug' #20

Closed
toby3d opened this issue Feb 4, 2020 · 7 comments
Closed

Comments

@toby3d
Copy link

toby3d commented Feb 4, 2020

Same as buaazp/fasthttprouter#49.

I want use / path for render index page and /:slug for render specific content by it's :slug. I am aware about the hack through router.NotFound, but, firstly, this is not most obvious way, and secondly, it requires additional validations for the correct transitions between the necessary pages.

Example

func main() {
	...
	
	r := router.New()
	handler.RegisterAPI(r.Group("/api")) // api
	handler.RegisterTemplates(r) // renders
}

func (h *MyHandlers) RegisterTemplates(g *router.Router) {
	g.GET("/", h.RenderIndex)
	g.GET("/:slug", h.RenderSlug)
}


func (h *MyHandlers) RegisterAPI(g *router.Router) {
	g.GET("/", h.ShowAll)
	g.GET("/:slug", h.ShowOne)
}
@savsgio
Copy link
Member

savsgio commented Feb 11, 2020

Hi @toby3d,

I will try to discover the error and i will fix it.

Thanks for issue.

@savsgio
Copy link
Member

savsgio commented Feb 17, 2020

Hi @toby3d,

Which values could have the :slug parameter?

@toby3d
Copy link
Author

toby3d commented Feb 17, 2020

Any alphanum combinations and '-', like: 'hello-world', 'answer42', '300-is-not-200' and so on.

In general, I expect that any parameter in the root (/:slug, /:page/raw, /:player/vs/:enemy and etc.) will work same as any other parameters in any other routes (/user/:user, /hello/:first/:last).

@savsgio
Copy link
Member

savsgio commented Feb 24, 2020

I'm researching about the issue.
When I have something, I will tell here.

@savsgio
Copy link
Member

savsgio commented Mar 3, 2020

I'm working for make the router more flexible, but i will take a few more days.

@toby3d

@toby3d
Copy link
Author

toby3d commented Mar 3, 2020

@savsgio That's ok, take your time. 👍🏻

@savsgio
Copy link
Member

savsgio commented Mar 8, 2020

I've been fixed it on branch master.

Soon, i will release a new version!

Thanks

@savsgio savsgio closed this as completed Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants