Pass query parameters as action arguments
jasny opened this issue · comments
Arnold Daniels commented
It should be trivial to switch from a path variable to a query parameter (or vice-versa). Using different actions prevents having to deal with too many situations in one action.
The syntax might be;
[
"GET /users?(page={page})" => ["action" => "list-users"],
"GET /users?filter={filter}&(page={page})" => ["action" => "query-users"],
"GET /users?search={search}&(page={page})" => ["action" => "search-users"],
]
Using round braces means the query parameter is optional. In the above situation the list-users-filtered
action is invoked if the request has a filter
parameter.
Challenge is that if all query parameters that aren't defined are ignored, the first route is also valid if there is a filter
query parameter. Also if a request has both a search
and filter
query param, what should be used?