Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom MIME Type Support #310

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Templates/ODataStartup.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,14 @@ namespace <NAMESPACE>
app.UseSwaggerUI(swaggerUiOptions)

;;Enable serving static files

data staticFilesProvider, @FileExtensionContentTypeProvider
AddCustomMimeTypes(staticFilesProvider)
app.UseDefaultFiles()
app.UseStaticFiles()
if (staticFilesProvider == ^null) then
app.UseStaticFiles()
else
app.UseStaticFiles(new StaticFileOptions() { ContentTypeProvider = staticFilesProvider })

app.UsePathBase(new PathString("/<SERVER_BASE_PATH>/v1"))

Expand Down Expand Up @@ -683,6 +689,19 @@ namespace <NAMESPACE>
required in provider, @DataObjectProvider
endmethod

;;; <summary>
;;; Declare the AddCustomMimeTypes partial method.
;;; Developers can use this to add support for custom mime types to the kestrel server
;;; </summary>
;;; <param name="provider">Returns an instance of FileExtensionContentTypeProvider</param>
partial method AddCustomMimeTypes, void
required out provider, @FileExtensionContentTypeProvider
;An example of how to implement this partial method:
;proc
; provider = new FileExtensionContentTypeProvider()
; provider.Mappings.Add(".apk","application/vnd.android.package-archive")
endmethod

.endregion

private static method findRelativeFolderForAssembly, string
Expand Down