This commit is contained in:
hoteas 2019-05-19 15:33:01 +00:00
parent 029325df54
commit a3d3155e9b
2 changed files with 41 additions and 43 deletions

View File

@ -4,15 +4,15 @@ import (
"bytes"
"database/sql"
"encoding/json"
"fmt"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"path/filepath"
"strconv"
"strings"
"net/url"
)
type Application struct {
@ -39,9 +39,6 @@ func (this *Application) ServeHTTP(w http.ResponseWriter, req *http.Request) {
//启动实例
func (this *Application) Run(router Router) {
this.Router = router
//重新设置MethodRouter//直达路由
this.MethodRouter = MethodRouter{}
@ -72,7 +69,6 @@ func (this *Application) Run(router Router) {
}
}
//this.Port = port
this.Port = this.Config.GetString("port")
@ -239,7 +235,6 @@ func (this *Application) urlSer(url string) (string, []string) {
//访问
func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
o, s := this.urlSer(req.RequestURI)
@ -284,7 +279,6 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
//url去掉参数并序列化
context.HandlerStr, context.RouterString = this.urlSer(context.HandlerStr)
//访问拦截true继续false暂停
connectListenerLen := len(this.connectListener)
if connectListenerLen != 0 {
@ -357,6 +351,10 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
header.Set("Cache-Control", "public")
}
if strings.Index(path, ".m3u8") != -1 {
header.Add("Content-Type", "audio/mpegurl")
}
//w.Write(data)
http.ServeFile(w, req, path)

View File

@ -1,4 +1,3 @@
package hotime
var MimeMaps = map[string]string{
@ -12,6 +11,7 @@ var MimeMaps = map[string]string{
".abc": "text/vndabc",
".ace": "application/x-ace-compressed",
".acgi": "text/html",
".m3u8": "audio/mpegurl",
".afl": "video/animaflex",
".ai": "application/postscript",
".aif": "audio/aiff",