private static IHandlerBuilder GetHandler(RouteConfiguration config) { var layout = Layout.Create(); var content = GetContent(config); if (content != null) { layout.Fallback(content); } else if (config.Listing != null) { layout.Fallback(Listing.From(ResourceTree.FromDirectory(config.Listing))); } else if (config.Content != null) { if (config.Content.Directory != null) { var directory = Resources.From(ResourceTree.FromDirectory(config.Content.Directory)); var staticContent = Layout.Create().Fallback(directory); if (config.Content.Index != null) { var indexFile = Path.Combine(config.Content.Directory, config.Content.Index); layout.Index(Download.From(Resource.FromFile(indexFile))); } layout.Fallback(staticContent); } } if (config.Routes != null) { foreach (var route in config.Routes) { layout.Add(route.Key, GetHandler(route.Value)); } } return(layout); }