private void ConfigureWebApi(IAppBuilder app, HostConfig config) { HttpConfiguration httpConfig = new HttpConfiguration(); // default routing - use routing attributes instead //httpConfig.Routes.MapHttpRoute( // name: "DefaultApi", // routeTemplate: "api/{controller}/{id}", // defaults: new { id = RouteParameter.Optional } //); // use routing attributes httpConfig.MapHttpAttributeRoutes(); // remove XML formatter httpConfig.Formatters.Remove(httpConfig.Formatters.XmlFormatter); // camel case DTO property names var jsonSettings = httpConfig.Formatters.JsonFormatter.SerializerSettings; jsonSettings.Formatting = Newtonsoft.Json.Formatting.Indented; jsonSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // make any configuration required by Sales API NovaBurst.ModularTypeScript.AppX.Sales.WebApi.WebApiConfig.Configure(httpConfig); // use Web API app.UseWebApi(httpConfig); // check for errors httpConfig.EnsureInitialized(); }
private void ConfigureFileServer(IAppBuilder app, HostConfig config) { // use a file server to serve all static content (js, css, content, html, ...) and also configure default files (eg: index.html to be the default entry point) // create file system that will locate the files var fileSystem = AggregateFileSystem.FromWebUiPhysicalPaths(config.RootDirectory); // setup default documents app.UseDefaultFiles(new DefaultFilesOptions { FileSystem = fileSystem, DefaultFileNames = new List<string> { "views/index.html" } }); // start file server to share website static content // wrapper around: StaticFiles + DefaultFiles + DirectoryBrowser var fileServerOptions = new FileServerOptions { EnableDirectoryBrowsing = false, FileSystem = fileSystem, }; fileServerOptions.StaticFileOptions.ContentTypeProvider = new FileServerContentTypeProvider(); app.UseFileServer(fileServerOptions); }