Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Last active November 18, 2015 16:18
Show Gist options
  • Select an option

  • Save panesofglass/9e4ccbfd806875cf57c6 to your computer and use it in GitHub Desktop.

Select an option

Save panesofglass/9e4ccbfd806875cf57c6 to your computer and use it in GitHub Desktop.
Nancy ResourceModule
using NancyFx.Resource;
public class MyResource : ResourceModule
{
public MyResource("/", {
Get = () => ...
})
}
namespace NancyFx.Resource
{
public class ResourceModule : NancyModule
{
public ResourceModule(string path, ResourceDescription description)
{
if (description.Get != null) Get[path] = description.Get;
if (description.Put != null) Put[path] = description.Put;
if (description.Post != null) Post[path] = description.Post;
if (description.Delete != null) Delete[path] = description.Delete;
}
}
public class ResourceDescription
{
public Func<dynamic, dynamic> Get { get; set; }
public Func<dynamic, dynamic> Put { get; set; }
public Func<dynamic, dynamic> Post { get; set; }
public Func<dynamic, dynamic> Delete { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment