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

MIGRATED: Pattern aliases - introduces ability to register aliases for some often used regular expressions. #16

Open
tebruno99 opened this issue Dec 15, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@tebruno99
Copy link

MIGRATED - See upstream comments

From Original PR: @HiveTraum gorilla#675 and gorilla#598
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
@tebruno99 tebruno99 added the enhancement New feature or request label Dec 15, 2022
@tebruno99 tebruno99 self-assigned this Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant