The Slim Framework support forum has moved to http://discourse.slimframework.com.
This Tender forum is no longer maintained or monitored.
Can I have a GET request with variable number of parameters in the url?
Can I do something like this?
Slim Version: 1.6.0
For example:
http://www.thisismypage.com/api/getitems/seafood/fruit
(will give me items categorized with 'seafood' or 'fruit')
http://www.thisismypage.com/api/getitems/meat
(will give me items categorized with 'meat')
http://www.thisismypage.com/api/getitems/petfood/fruit
(will give me items categorized with 'petfood' or 'fruit')
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Andrew Smith on 08 Jun, 2012 09:59 AM
This can be done, its all down to your coding you can pass optional params to Slim it would be down to you how the logic of this works.
2 Posted by ywndaniel on 08 Jun, 2012 12:42 PM
Even the number of criteria is unknown?
http://www.thisismypage.com/api/getitems/(petfood/fruit) << now 2 criteria
It can be 1, 2, ... 100, ..., 1000 criterias
I got 404 Page Not Found when I do this
http://www.thisismypage.com/api/test/aaa/bbb/ccc
Support Staff 3 Posted by Andrew Smith on 08 Jun, 2012 12:49 PM
I spoke to Josh and wildcard catchall routes won't be available until 1.7, so currently you will have to think of another option.
You would get an 404 not found since you are passing 3 params and Slim is looking for max 2 params.
Support Staff 4 Posted by Brian Nesbitt on 18 Jun, 2012 04:11 PM
This is actually possible using route conditions and route middleware to perform the parsing.
I blogged about it here:
http://nesbot.com/2012/6/18/slim-wildcard-routes-via-route-middleware
5 Posted by ywndaniel on 18 Jun, 2012 11:24 PM
super detail and useful!!
thank you very much!!
Brian Nesbitt closed this discussion on 29 Jun, 2012 01:16 PM.