diff --git a/main.go b/main.go index a2a2359..5e70a17 100644 --- a/main.go +++ b/main.go @@ -5,11 +5,11 @@ import ( "flag" "html/template" "math/rand" + "mime" "net/http" "runtime" "strconv" "time" - "mime" "github.com/b3log/wide/conf" "github.com/b3log/wide/editor" @@ -274,14 +274,10 @@ func aboutHandler(w http.ResponseWriter, r *http.Request) { // 主程序入口. func main() { - - //解决Windows环境下问题 - mime.AddExtensionType(".css", "text/css") - mime.AddExtensionType(".js", "application/x-javascript") - mime.AddExtensionType(".json", "application/json") - runtime.GOMAXPROCS(conf.Wide.MaxProcs) + initMime() + defer glog.Flush() // IDE @@ -387,3 +383,12 @@ func panicRecover(handler func(w http.ResponseWriter, r *http.Request)) func(w h handler(w, r) } } + +// 初始化 mime. +// +// 有的操作系统(例如 Windows XP)上运行时根据文件后缀获取不到对应的 mime 类型,会导致响应的 HTTP content-type 不正确。 +func initMime() { + mime.AddExtensionType(".css", "text/css") + mime.AddExtensionType(".js", "application/x-javascript") + mime.AddExtensionType(".json", "application/json") +} diff --git a/wide-ide.bat b/wide.bat similarity index 66% rename from wide-ide.bat rename to wide.bat index 570da4e..4fdf252 100644 --- a/wide-ide.bat +++ b/wide.bat @@ -1,3 +1,5 @@ go install + wide -pause \ No newline at end of file + +pause