Skip to content

Instantly share code, notes, and snippets.

@ianbattersby
Last active December 17, 2015 21:09
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 ianbattersby/5672963 to your computer and use it in GitHub Desktop.
Save ianbattersby/5672963 to your computer and use it in GitHub Desktop.
namespace Bazinga
{
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using Fix;
using Microsoft.Owin.Hosting;
using Owin;
using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>;
internal class Program
{
public static readonly string Location = Path.GetDirectoryName(typeof(Simple.Web.Behaviors.IETag).Assembly.Location);
private static void Main(string[] args)
{
var simpleWeb = BuildApp();
var startOptions = new StartOptions("http://localhost:55000");
using (WebApp.Start(
startOptions,
app =>
{
app.UseErrorPage();
app.Use(new Func<AppFunc, AppFunc>(ignoreNextApp => (AppFunc)simpleWeb.Invoke));
}))
{
Console.WriteLine("Katana: listening at {0}. Press CTRL-C to stop.", hostname);
Console.ReadKey();
}
}
private static AppFunc BuildApp()
{
var fixer = new Fixer();
using (var catalog = new AggregateCatalog())
{
catalog.Catalogs.Add(new AssemblyCatalog(typeof(Simple.Web.Behaviors.IETag).Assembly));
var container = new CompositionContainer(catalog);
container.ComposeParts(fixer);
}
return fixer.BuildApp();
}
}
public sealed class PathUtility : IPathUtility
{
public string MapPath(string virtualPath)
{
return Path.Combine(Program.Location, virtualPath.TrimStart('/').Replace('/', Path.DirectorySeparatorChar));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment