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

Route Constraints #1089

Closed
Blacksmoke16 opened this issue Apr 2, 2019 · 1 comment · Fixed by #1090
Closed

Route Constraints #1089

Blacksmoke16 opened this issue Apr 2, 2019 · 1 comment · Fixed by #1090

Comments

@Blacksmoke16
Copy link
Contributor

Since amberframework/amber-router#12 was merged Amber supports adding constraints to its routes, like https://guides.rubyonrails.org/routing.html#segment-constraints.

However there is not currently a method of defining these on a given route/resource.

Should be pretty simple like

get "/user/:id", UserController, :show, constraints: {id: /\d+/}

Then just pass the constraints to the router when adding the route.

@kvirani
Copy link
Contributor

kvirani commented Apr 3, 2019

I'd like to take a stab at this, and in doing so get more comfortable with the amber source code. No guarantees though.

kvirani added a commit to kvirani/amber that referenced this issue Apr 7, 2019
- Resolves amberframework#1089
- Pass constraints through to amber-router's RouteSet: https://github.com/amberframework/amber-router/blob/master/spec/amber_router/route_set/matching/routes_with_variables_spec.cr#L41
- Only Hashes are supported atm. Not sure if we should also be supporting NamedTuple here. Looking for feedback there.
elorest pushed a commit that referenced this issue Apr 25, 2019
* Add constraints support for routes

- Resolves #1089
- Pass constraints through to amber-router's RouteSet: https://github.com/amberframework/amber-router/blob/master/spec/amber_router/route_set/matching/routes_with_variables_spec.cr#L41
- Only Hashes are supported atm. Not sure if we should also be supporting NamedTuple here. Looking for feedback there.

* Fix trailing white spaces

Thanks ameba

* crystal tool format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants