Last active
November 18, 2015 16:18
-
-
Save panesofglass/9e4ccbfd806875cf57c6 to your computer and use it in GitHub Desktop.
Nancy ResourceModule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using NancyFx.Resource; | |
| public class MyResource : ResourceModule | |
| { | |
| public MyResource("/", { | |
| Get = () => ... | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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