Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ServiceStack route definition for a parameter that is an array

Tags:

servicestack

I have a service that will return top N items in sales given a bunch of different criteria. So if I have a GET route, how do I set the route to handle an array of a certain parameter?

Top 100 items for group A,C,D,E,F for the current week. Top 100 items for store 1,10,11,18,40 for the current month.

How could the route be structured to handle this?

like image 953
LiteWait Avatar asked Sep 19 '12 12:09

LiteWait


1 Answers

Its already wired up for you. For the groups example the route declaration will look like this:

Items/{Groups}

The Items DTO will need this property

public string[] Groups { get; set; }

Then you can just call it like so /Items/A,C,D,E,F

The array will get populated correctly.

like image 64
kampsj Avatar answered Nov 26 '22 16:11

kampsj