Beispiel #1
0
func (m *mimeDetector) mimeTypeForPath(p gopath.GoPath) string {
	p = p.EvalSymlinks()
	if p.IsDirectory() || p.HasErr() {
		return store.FallbackMimeType
	}

	var ext = p.Ext()
	if mimeType := mime.TypeByExtension(ext); mimeType != "" {
		return mimeType
	}

	var first512Bytes = m.first512BytesForPath(p)
	m.errAndClear() // clear error flag, as DetectContentType always returns something

	return http.DetectContentType(first512Bytes)
}