move initmime from beego.Run to hookfunc
Showing
2 changed files
with
4 additions
and
4 deletions
| ... | @@ -18,6 +18,8 @@ var hooks []hookfunc //hook function slice to store the hookfunc | ... | @@ -18,6 +18,8 @@ var hooks []hookfunc //hook function slice to store the hookfunc |
| 18 | 18 | ||
| 19 | func init() { | 19 | func init() { |
| 20 | hooks = make([]hookfunc, 0) | 20 | hooks = make([]hookfunc, 0) |
| 21 | //init mime | ||
| 22 | AddAPPStartHook(initMime) | ||
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | // Router adds a patterned controller handler to BeeApp. | 25 | // Router adds a patterned controller handler to BeeApp. |
| ... | @@ -112,9 +114,6 @@ func Run() { | ... | @@ -112,9 +114,6 @@ func Run() { |
| 112 | } | 114 | } |
| 113 | } | 115 | } |
| 114 | 116 | ||
| 115 | //init mime | ||
| 116 | initMime() | ||
| 117 | |||
| 118 | // do hooks function | 117 | // do hooks function |
| 119 | for _, hk := range hooks { | 118 | for _, hk := range hooks { |
| 120 | err := hk() | 119 | err := hk() | ... | ... |
| ... | @@ -544,8 +544,9 @@ var mimemaps map[string]string = map[string]string{ | ... | @@ -544,8 +544,9 @@ var mimemaps map[string]string = map[string]string{ |
| 544 | ".mustache": "text/html", | 544 | ".mustache": "text/html", |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | func initMime() { | 547 | func initMime() error { |
| 548 | for k, v := range mimemaps { | 548 | for k, v := range mimemaps { |
| 549 | mime.AddExtensionType(k, v) | 549 | mime.AddExtensionType(k, v) |
| 550 | } | 550 | } |
| 551 | return nil | ||
| 551 | } | 552 | } | ... | ... |
-
Please register or sign in to post a comment