github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/setting/mime_type_map.go (about)

     1  // Copyright 2023 The GitBundle Inc. All rights reserved.
     2  // Copyright 2017 The Gitea Authors. All rights reserved.
     3  // Use of this source code is governed by a MIT-style
     4  // license that can be found in the LICENSE file.
     5  
     6  package setting
     7  
     8  import "strings"
     9  
    10  // MimeTypeMap defines custom mime type mapping settings
    11  var MimeTypeMap = struct {
    12  	Enabled bool
    13  	Map     map[string]string
    14  }{
    15  	Enabled: false,
    16  	Map:     map[string]string{},
    17  }
    18  
    19  func newMimeTypeMap() {
    20  	sec := Cfg.Section("repository.mimetype_mapping")
    21  	keys := sec.Keys()
    22  	m := make(map[string]string, len(keys))
    23  	for _, key := range keys {
    24  		m[strings.ToLower(key.Name())] = key.Value()
    25  	}
    26  	MimeTypeMap.Map = m
    27  	if len(keys) > 0 {
    28  		MimeTypeMap.Enabled = true
    29  	}
    30  }