diff --git a/main.go b/main.go index ca6b9d9..5e70a17 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "flag" "html/template" "math/rand" + "mime" "net/http" "runtime" "strconv" @@ -275,6 +276,8 @@ func aboutHandler(w http.ResponseWriter, r *http.Request) { func main() { runtime.GOMAXPROCS(conf.Wide.MaxProcs) + initMime() + defer glog.Flush() // IDE @@ -380,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.bat b/wide.bat new file mode 100644 index 0000000..4fdf252 --- /dev/null +++ b/wide.bat @@ -0,0 +1,5 @@ +go install + +wide + +pause