Skip to content

Instantly share code, notes, and snippets.

@khellang
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save khellang/8851016 to your computer and use it in GitHub Desktop.

Select an option

Save khellang/8851016 to your computer and use it in GitHub Desktop.
public class MyModule : NancyModule
{
public MyModule()
{
Post["/scores"] = _ =>
{
var queries = this.Bind<IEnumerable<QueryParameters>>();
return queries.Select(GetResult);
}
Get["/scores"] = args =>
{
var query = new QueryParameters
{
StartDate = args.startDate,
EndDate = args.endDate,
Team = args.team;
}
return GetResult(query);
}
}
private Result GetResult(QueryParameters parameters)
{
// Get some results
}
}
public class QueryParameters
{
public DateTimeOffset StartDate { get; set; }
public DateTimeOffset EndDate { get; set; }
public string Team { get; set; }
}
public class Result
{
// Watever you want to return here...
}
[{
startDate: 01-04-2013,
endDate: 01-05-2013,
team: "Jets"
},
{
startDate: 01-04-2013,
endDate: 01-05-2013,
team: "Cowboys"
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment