/// <summary> /// Constructor of AngularServerMiddleware. There are two parameters: "next" and "options". /// </summary> /// <param name="next">An AppFunc delegation.</param> /// <param name="options">An AngularServerOptions</param> public AngularServerMiddleware(AppFunc next, AngularServerOptions options) { _next = next; _options = options; _innerMiddleware = new StaticFileMiddleware(next, options.FileServerOptions.StaticFileOptions); }
/// <summary> /// Extension class for OWIN self-hosted web to work with AngularJS, /// especially when the html5Mode is enabled in AngularJS. /// </summary> /// <param name="builder">Owin.IAppBuilder interface</param> /// <param name="rootPath">The root path of the web using AngularJS. Default value is "/".</param> /// <param name="entryPath">The entry/redirect page. Default value is "/index.html".</param> /// <returns>Returns a public static type of OWIN.IAppBuilder.</returns> public static IAppBuilder UseAngularServer(this IAppBuilder builder, string rootPath = "/", string entryPath = "/index.html") { var options = new AngularServerOptions() { FileServerOptions = new FileServerOptions() { EnableDirectoryBrowsing = false, FileSystem = new PhysicalFileSystem(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rootPath)) }, EntryPath = new PathString(entryPath) }; builder.UseDefaultFiles(options.FileServerOptions.DefaultFilesOptions); return(builder.Use(new Func <AppFunc, AppFunc>(next => new AngularServerMiddleware(next, options).Invoke))); }