mirror of https://github.com/go-gitea/gitea
Add mimetype mapping settings (#15133)
* Fix APK's Content-Type header * Fix case sensitive comparison * Add custom mime type mapping for downloadable files * Add documentation for MIME type mapping * Rename download.mimetype.mapping configuration to repository.mimetype_mapping Co-authored-by: zeripath <art27@cantab.net>pull/15689/head^2
parent
2f65c6b2f0
commit
d86d123322
@ -0,0 +1,31 @@ |
||||
// Copyright 2021 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package setting |
||||
|
||||
import "strings" |
||||
|
||||
var ( |
||||
// MimeTypeMap defines custom mime type mapping settings
|
||||
MimeTypeMap = struct { |
||||
Enabled bool |
||||
Map map[string]string |
||||
}{ |
||||
Enabled: false, |
||||
Map: map[string]string{}, |
||||
} |
||||
) |
||||
|
||||
func newMimeTypeMap() { |
||||
sec := Cfg.Section("repository.mimetype_mapping") |
||||
keys := sec.Keys() |
||||
m := make(map[string]string, len(keys)) |
||||
for _, key := range keys { |
||||
m[strings.ToLower(key.Name())] = key.Value() |
||||
} |
||||
MimeTypeMap.Map = m |
||||
if len(keys) > 0 { |
||||
MimeTypeMap.Enabled = true |
||||
} |
||||
} |
Loading…
Reference in new issue