pretzel icon indicating copy to clipboard operation
pretzel copied to clipboard

Make it possible to specify custom mime types for taste

Open biohazard999 opened this issue 5 years ago • 0 comments

I'm currently making static sites to download apps via msix. Cause the windows10 app installer needs specialized mime types I need a way to specify them for easier testing.

Proposed solution: Similar approach like dotnet-serve does: Add command line parameters that accept mime types with extention.

Second option would be a mime-type list in _config.yml to specify them permanently for the project. Maybe we could provide both options.

Technically it's an easy change: AspNetCoreWebHost.cs

   var contentTypeProvider = new FileExtensionContentTypeProvider();

            contentTypeProvider.Mappings[".appx"] = "application/appx";
            contentTypeProvider.Mappings[".msix"] = "application/msix";
            contentTypeProvider.Mappings[".appxbundle"] = "application/appxbundle";
            contentTypeProvider.Mappings[".msixbundle"] = "application/msixbundle";
            contentTypeProvider.Mappings[".appinstaller"] = "application/appinstaller";

  webHost = WebHost.CreateDefaultBuilder()
                .ConfigureLogging(l =>
                {
                    if (!Debug) l.ClearProviders();
                })
                .ConfigureKestrel(k => k.ListenLocalhost(Port))
                .Configure(config => config.UseDefaultFiles().UseStaticFiles(new StaticFileOptions
                {
                    ContentTypeProvider = contentTypeProvider
                }))
                .UseWebRoot(BasePath).Build();

biohazard999 avatar Dec 12 '19 10:12 biohazard999