MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / getContentType

Function getContentType

src/webserver.go:1474–1500  ·  view source on GitHub ↗
(filename string)

Source from the content-addressed store, hash-verified

1472}
1473
1474func getContentType(filename string) (contentType string) {
1475
1476 mimeTypes := map[string]string{
1477 ".html": "text/html",
1478 ".css": "text/css",
1479 ".js": "application/javascript",
1480 ".png": "image/png",
1481 ".jpg": "image/jpeg",
1482 ".jpeg": "image/jpeg",
1483 ".gif": "image/gif",
1484 ".svg": "image/svg+xml",
1485 ".ico": "image/x-icon",
1486 ".webp": "image/webp",
1487 ".mp4": "video/mp4",
1488 ".webm": "video/webm",
1489 ".ogg": "video/ogg",
1490 ".mp3": "audio/mp3",
1491 ".wav": "audio/wav",
1492 }
1493
1494 // Extract the file extension and normalize it to lowercase
1495 ext := strings.ToLower(path.Ext(filename))
1496 if contentType, exists := mimeTypes[ext]; exists {
1497 return contentType
1498 }
1499 return "text/plain"
1500}

Callers 3

ImagesFunction · 0.85
DataImagesFunction · 0.85
WebFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected