gogearbox/gearbox

Support parameters in paths

abahmed opened this issue · 3 comments

Allow user to specify parameters in paths while adding routes (e.g. gearbox.Get("/user/:name, ...)).

Discussions / suggestions is open here

  • The proper delimiter (:name, or {name})
  • How these parameters will be passed to handler

@abahmed @muhammednagy - I'm happy to dive into this one, would want to run my thoughts by you all.

  1. I personally prefer the :name notation as to me it is just visually cleaner. The only other supporting argument may be that using :name does not conflict with common regex syntax (if we introduced more advanced regex matching in routes). For example, I think /users/([0-9]{4})/:product is preferable to /users/([0-9]{4})/{product}.
  2. Do we think this is dependent on #11 ? I believe will eventually need to parse path parameters out of the Ternary Search Tree. We can attempt to proceed in a manner that is independent of whether the nodes of the TST are of type []byte or string.

Let me know what you guys think 👍

Thanks @raubrey2014 :-)

  1. I do agree with you on using ":" delimiter
  2. Yes, agree with you too. They affect each other but they are not blocking each other.

I pretty much agree.
':' does make more sense yes.