Skip to content

Instantly share code, notes, and snippets.

@InvaderZim85
Last active November 22, 2019 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InvaderZim85/9fda89e17077bc7cf65450ce3114944f to your computer and use it in GitHub Desktop.
Save InvaderZim85/9fda89e17077bc7cf65450ce3114944f to your computer and use it in GitHub Desktop.
Usage of the custom attribute
public sealed class InfoModule : NancyModule
{
[RouteDescription("HelloRoute", "Returns a simple hello message.")]
[RouteDescription("InfoRoute", "Returns the current date time and a short hello message.")]
public InfoModule()
{
Get("/", _ => Response.AsText("Hello from Nancy!", name: "HelloRoute");
Get("/info", _ =>
{
var info = new
{
Date = DateTime.Now,
Message = "Hello World!"
};
return Response.AsJson(info);
}, name: "InfoRoute");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment