Simplify pkg mimedb (#6549)

Content-Type resolution can now use a function `TypeByExtension(extension)` 
to resolve to the respective content-type.
This commit is contained in:
Praveen raj Mani
2018-10-02 11:48:17 +05:30
committed by Nitish Tiwari
parent f163bed40d
commit c7722fbb1b
6 changed files with 54 additions and 34 deletions

View File

@@ -29,3 +29,17 @@ func TestMimeLookup(t *testing.T) {
t.Fatalf("Invalid content type are found expected \"false\", got %t", compressible)
}
}
func TestTypeByExtension(t *testing.T) {
var contentType string
// Test TypeByExtension.
contentType = TypeByExtension(".txt")
if contentType != "text/plain" {
t.Fatalf("Invalid content type are found expected \"text/plain\", got %s", contentType)
}
// Test non-existent type resolution
contentType = TypeByExtension(".abc")
if contentType != "application/octet-stream" {
t.Fatalf("Invalid content type are found expected \"application/octet-stream\", got %s", contentType)
}
}