Created
April 3, 2013 19:46
-
-
Save davepermen/5304607 to your computer and use it in GitHub Desktop.
Static File Content Stuff
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 FileContent | |
{ | |
NancyConventions conventions; | |
public FileContent(NancyConventions conventions) | |
{ | |
this.conventions = conventions; | |
} | |
public string this[string requestFile] | |
{ | |
set | |
{ | |
conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddFile(requestFile, value)); | |
} | |
} | |
} | |
public class DirectoryContent | |
{ | |
NancyConventions conventions; | |
public DirectoryContent(NancyConventions conventions) | |
{ | |
this.conventions = conventions; | |
} | |
public string this[string requestDirectory] | |
{ | |
set | |
{ | |
conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory(requestDirectory, value)); | |
} | |
} | |
} | |
public static class StaticContent | |
{ | |
public static void Static(this NancyConventions conventions, Action<FileContent, DirectoryContent> staticConventions) | |
{ | |
staticConventions(new FileContent(conventions), new DirectoryContent(conventions)); | |
} | |
} |
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 Boostrapper : DefaultNancyBootstrapper | |
{ | |
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines) | |
{ | |
StaticConfiguration.DisableErrorTraces = false; | |
StaticConfiguration.Caching.EnableRuntimeViewUpdates = true; | |
CookieBasedSessions.Enable(pipelines); | |
base.ApplicationStartup(container, pipelines); | |
} | |
protected override void ConfigureConventions(NancyConventions conventions) | |
{ | |
base.ConfigureConventions(conventions); | |
conventions.Static((File, Directory) => | |
{ | |
File["/page.js"] = "page.min.js"; | |
File["/page.css"] = "page.min.css"; | |
File["/page.min.js.map"] = "page.min.js.map"; | |
File["/html5.js"] = "Scripts/html5shiv.js"; | |
Directory["/images"] = "images"; | |
Directory["/fonts"] = "fonts"; | |
Directory["/flyers"] = "flyers"; | |
Directory["/backgrounds"] = "backgrounds"; | |
Directory["/events"] = "events"; | |
}); | |
} | |
} |
clear and simple and is like the route syntax in the modules,i can't wait to test it
very nice!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like it.