(filename string)
| 1472 | } |
| 1473 | |
| 1474 | func 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 | } |
no outgoing calls
no test coverage detected