Search code examples
c#apirestopenrasta

Passing an object as a parameter in openrasta get method


Is it possible for an OpenRasta handler to have accept a resource as a parameter.
For a URI of (for example) "/search/" could I pass something like:

public class SearchRequest
{
  public string Term { get; set; }
  public string[] Categories { get; set; }
  public int LimitPerPage { get; set; }
  public int CurrentPage { get; set; }
}

In my handler, have something like:

public List<SearchResult> Get(SearchRequest request)

Or am I better composing my URI with those as parameters for the querystring?


Solution

  • If you have a GET you'll have to declare the parameters you expect in the URI. You can simply have /search?page={CurrentPage} declared in AtUri.