Skip to content

Commit

Permalink
Merge pull request PelicanPlatform#1671 from CannonLock/patch-mimetypes
Browse files Browse the repository at this point in the history
Fix mimetypes for web responses
  • Loading branch information
CannonLock authored Oct 22, 2024
2 parents 16fae5f + 886415d commit 602465f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions web_ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,27 @@ func handleWebUIResource(ctx *gin.Context) {
file, _ := webAssets.ReadFile(notFoundFilePath)
ctx.Data(
http.StatusNotFound,
mime.TypeByExtension(notFoundFilePath),
mime.TypeByExtension(path.Ext(notFoundFilePath)),
file,
)
} else {
// If the file is found, return the file
ctx.Data(
http.StatusOK,
mime.TypeByExtension(filePath),
mime.TypeByExtension(path.Ext(filePath)),
file,
)
}
}

func configureWebResource(engine *gin.Engine) {

// Register the MIME type for .txt files
err := mime.AddExtensionType(".txt", "text/plain")
if err != nil {
log.Errorf("Failed to register MIME type: %v", err)
}

engine.GET("/view/*requestPath",
handleGlobusPages,
handleWebUIRedirect,
Expand Down

0 comments on commit 602465f

Please sign in to comment.