Is it possible in OpenRasta to have a Uri pattern that allows for an array of values of the same key to be submitted and mapped to a handler method accepting an array of the query parameters.
Example: Return all the contacts named Dave Smith from a collection.
HTTP GET /contacts?filterBy=first&filterValue=Dave&filterBy=last&filterValue=Smith
With a configuration of:
What syntax would be best for the Uri string pattern matching? (Suggestions welcome)
ResourceSpace.Has.ResourcesOfType<List<ContactResource>>()
.AtUri("/contacts")
.And.AtUri("/contacts?filterBy[]={filterBy}[]&filterValue[]={fv}[]") // Option 1
.And.AtUri("/contacts?filterBy={filterBy}[]&fv={fv}[]") // Option 2
Would map to a Handler method of:
public object Get(params Filter[] filters)
{
/*
create a Linq Expression based on the filters using dynamic linq
query the repository using the Linq
*/
return Query.All<Contact>().Where(c => c.First == "Dave" && c.Last == "Smith").ToResource()
}
where Filter is defined by
public class Filter
{
public string FilterBy { get; set; }
public string FilterValue { get; set; }
}