Created
June 13, 2013 11:06
-
-
Save caevyn/5772914 to your computer and use it in GitHub Desktop.
from davepermen.net i can now do this: http://localhost:7820/route/BlogModule and get back this [ "GET /", "GET /list/{pageId}", "GET /article/{id}", "GET /newArticle"
]
This file contains 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
public class RouteModule : NancyModule | |
{ | |
public RouteModule(IRouteCacheProvider routeCache) | |
{ | |
Get["/routes/all"] = _ => routeCache.GetCache().Select(entry => new | |
{ | |
Module = entry.Key.Name, | |
Routes = entry.Value.Select(route => route.Item2.Method + " " + route.Item2.Path) | |
}); | |
Get["/route/{moduleName}"] = _ => | |
routeCache.GetCache() | |
.Where(entry => entry.Key.Name == (string)_.moduleName) | |
.Select(entry => entry.Value.Select(route => route.Item2.Method + " " + route.Item2.Path)) | |
.FirstOrDefault(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment