Skip to content

Instantly share code, notes, and snippets.

@rhwy
Created November 26, 2014 17:16
Show Gist options
  • Save rhwy/72eb2936ad045b300f48 to your computer and use it in GitHub Desktop.
Save rhwy/72eb2936ad045b300f48 to your computer and use it in GitHub Desktop.
NancyFX returning struct as Json
public class HomeModule : NancyModule
{
public HomeModule ()
{
Get ["/"] = p => "hello";
Get ["/{id}/{user}"] = p => {
User user = new User(p.id,p.user);
return Negotiate.WithModel(user);
};
}
}
public struct User
{
public string Id;
public string Name;
public User (string id, string name)
{
this.Id = id;
this.Name = name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment