Skip to content

Instantly share code, notes, and snippets.

@bhameyie
Last active December 18, 2015 13:59
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 bhameyie/5794114 to your computer and use it in GitHub Desktop.
Save bhameyie/5794114 to your computer and use it in GitHub Desktop.
Simple Blog bootstrapper
public class BlogBootstrapper : AutofacNancyBootstrapper
{
protected override void ApplicationStartup(Autofac.ILifetimeScope container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
#if DEBUG
StaticConfiguration.DisableErrorTraces = false;
#endif
CookieBasedSessions.Enable(pipelines);
var builder = new ContainerBuilder();
builder.RegisterType<AuthenticatedUserProvider>().As<IUserMapper>();
builder.RegisterType<BlogServiceClient>().As<IBlogServiceClient>();
builder.RegisterType<AuthenticationServiceClientClient>().As<IAuthenticationServiceClient>();
builder.Update(container.ComponentRegistry);
var config = new FormsAuthenticationConfiguration
{
RedirectUrl = "~/",
UserMapper =container.Resolve<IUserMapper>()
};
FormsAuthentication.Enable(pipelines,config);
}
//Loads my css, Images & scripts
protected override void ConfigureConventions(NancyConventions conventions)
{
base.ConfigureConventions(conventions);
conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("Content", @"Content")
);
conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("Scripts", @"Scripts")
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment