Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created August 21, 2015 01:30
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 dcomartin/767273cc2fe6e7bdf2ba to your computer and use it in GitHub Desktop.
Save dcomartin/767273cc2fe6e7bdf2ba to your computer and use it in GitHub Desktop.
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Configure Web API for self-host.
var config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
// Adding to the pipeline with our own middleware
app.Use(async (context, next) =>
{
// Add Header
context.Response.Headers["X-Powered-By"] = "Owin Self Host";
// Call next middleware
await next.Invoke();
});
// Custom Middleare
app.Use(typeof(CustomMiddleware));
// Web Api
app.UseWebApi(config);
// Fik
var options = new FileServerOptions
{
EnableDirectoryBrowsing = true,
EnableDefaultFiles = true,
DefaultFilesOptions = { DefaultFileNames = {"index.html"}},
FileSystem = new PhysicalFileSystem("Assets"),
StaticFileOptions = { ContentTypeProvider = new CustomContentTypeProvider() }
};
app.UseFileServer(options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment