この回答IRouteCacheProvider
で言及されている@grumpydevのように使用する方法の例:
// within your module
public class IndexModule : NancyModule
{
// add dependency to IRouteCacheProvider
public IndexModule(Nancy.Routing.IRouteCacheProvider rc)
{
routeCache = rc;
Get["/"] = GetIndex;
}
private Nancy.Routing.IRouteCacheProvider routeCache;
private dynamic GetIndex(dynamic arg)
{
var response = new IndexModel();
// get the cached routes
var cache = routeCache.GetCache();
response.Routes = cache.Values.SelectMany(t => t.Select(t1 => t1.Item2));
return response;
}
}
public class IndexModel
{
public IEnumerable<Nancy.Routing.RouteDescription> Routes { get; set; }
}
Path
のMethod
リストのようなルーティング情報を取得できますNancy.Routing.RouteDescription
。たとえば、このビューでは:
<!DOCTYPE html>
<html>
<body>
<p>Available routes:</p>
<table>
<thead><tr><th>URL</th><th>Method</th></tr></thead>
<tbody>
@Each.Routes
<tr><td>@Current.Path</td><td>@Current.Method</td></tr>
@EndEach
</tbody>
</table>
</body>
</html>