Skip to content

Instantly share code, notes, and snippets.

@caevyn
Created June 13, 2013 11:06
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 caevyn/5772914 to your computer and use it in GitHub Desktop.
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" ]
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