livebud / bud

The Full-Stack Web Framework for Go
MIT License
5.58k stars 179 forks source link

Dynamic route does not support . (dot) #108

Closed lucky-bit closed 2 years ago

lucky-bit commented 2 years ago
  1. Define get route: router.Get(/:id, controller.Show)
  2. Define id as string // Show page // GET /:id func (c Controller) Show(ctx context.Context, id string) (story Story, err error) {
  3. Navigate to http://127.0.0.1:3000/some.value ===> 404 page not found
matthewmueller commented 2 years ago

Thanks for trying out Bud @lucky-bit!

I'd like to add support for this, but it will be more about specifying a file format, e.g. http://127.0.0.1:3000/some.json or http://127.0.0.1:3000/some.rss triggering the Some action. Does that work for your use case?

One other question:

Define get route:

I'm assuming you defined this in the controller/ package or did you use the router package manually?

lucky-bit commented 2 years ago

Hey @matthewmueller! Unfortunately file format and triggering action won't cover my case. I would like to present order details according to provided order id such as xyz.01234567 by visiting http://127.0.0.1:3000/xyz.01234567

I'm assuming you defined this in the controller/ package or did you use the router package manually?

No manual work, route created using bud new controller

matthewmueller commented 2 years ago

Ah, that's an interesting one. So basically /orders/:id, where :id is xyz.01234567? Out of curiousity, why are dots a requirement for an order id? Existing database?

At first glance, I'd probably follow what Rails decided to do in this case. Maybe that means defining a custom route?

(Converting this to a discussion since it's currently working as expected)