mux icon indicating copy to clipboard operation
mux copied to clipboard

pattern aliases

Open HiveTraum opened this issue 2 years ago • 4 comments

✋Reopened #598 because i noticed that the project came to life

This feature introduces ability to register aliases for some often used regular expressions.

For example path as this: /{category:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}}/{product:[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}} can be transformed into this /{category:uuid}/{product:uuid}

You need just use register it

router := NewRouter()
router.RegisterPattern("uuid", "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}")
router.Path("/{category:uuid}")
router.Path("/{product:uuid}")
router.Path("/{order:uuid}")
router.Path("/{user:uuid}")
  1. New method RegisterPattern on Route struct
  2. New method RegisterPattern on Router struct

HiveTraum avatar May 15 '22 05:05 HiveTraum

Thank you @HiveTraum for bringing this up again. I have added a couple of comments. I need some more time to review it completely. In the meantime, I Would love to hear from you.

amustaque97 avatar Jun 05 '22 21:06 amustaque97

@amustaque97 Done 👍

HiveTraum avatar Jun 06 '22 15:06 HiveTraum

@elithrar , I reviewed the PR and changes looks good to me and ready to ship 🚀

I would request you to please take a final look at this and if all good. Can we merge it?

amustaque97 avatar Jun 06 '22 18:06 amustaque97

Yes, it's ready to merge

HiveTraum avatar Dec 05 '22 05:12 HiveTraum