forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mimetype mapping settings (go-gitea#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>
- Loading branch information
1 parent
41157fa
commit 10810c2
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1177,4 +1177,5 @@ func NewServices() { | |
newTaskService() | ||
NewQueueService() | ||
newProject() | ||
newMimeTypeMap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters