This commit is contained in:
parent
029325df54
commit
a3d3155e9b
@ -4,15 +4,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"net/url"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Application struct {
|
type Application struct {
|
||||||
@ -39,9 +39,6 @@ func (this *Application) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
//启动实例
|
//启动实例
|
||||||
func (this *Application) Run(router Router) {
|
func (this *Application) Run(router Router) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.Router = router
|
this.Router = router
|
||||||
//重新设置MethodRouter//直达路由
|
//重新设置MethodRouter//直达路由
|
||||||
this.MethodRouter = MethodRouter{}
|
this.MethodRouter = MethodRouter{}
|
||||||
@ -72,7 +69,6 @@ func (this *Application) Run(router Router) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//this.Port = port
|
//this.Port = port
|
||||||
this.Port = this.Config.GetString("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) {
|
func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
o, s := this.urlSer(req.RequestURI)
|
o, s := this.urlSer(req.RequestURI)
|
||||||
@ -284,7 +279,6 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
//url去掉参数并序列化
|
//url去掉参数并序列化
|
||||||
context.HandlerStr, context.RouterString = this.urlSer(context.HandlerStr)
|
context.HandlerStr, context.RouterString = this.urlSer(context.HandlerStr)
|
||||||
|
|
||||||
|
|
||||||
//访问拦截true继续false暂停
|
//访问拦截true继续false暂停
|
||||||
connectListenerLen := len(this.connectListener)
|
connectListenerLen := len(this.connectListener)
|
||||||
if connectListenerLen != 0 {
|
if connectListenerLen != 0 {
|
||||||
@ -357,6 +351,10 @@ func (this *Application) handler(w http.ResponseWriter, req *http.Request) {
|
|||||||
header.Set("Cache-Control", "public")
|
header.Set("Cache-Control", "public")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Index(path, ".m3u8") != -1 {
|
||||||
|
header.Add("Content-Type", "audio/mpegurl")
|
||||||
|
}
|
||||||
|
|
||||||
//w.Write(data)
|
//w.Write(data)
|
||||||
http.ServeFile(w, req, path)
|
http.ServeFile(w, req, path)
|
||||||
|
|
||||||
|
2
mime.go
2
mime.go
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package hotime
|
package hotime
|
||||||
|
|
||||||
var MimeMaps = map[string]string{
|
var MimeMaps = map[string]string{
|
||||||
@ -12,6 +11,7 @@ var MimeMaps = map[string]string{
|
|||||||
".abc": "text/vndabc",
|
".abc": "text/vndabc",
|
||||||
".ace": "application/x-ace-compressed",
|
".ace": "application/x-ace-compressed",
|
||||||
".acgi": "text/html",
|
".acgi": "text/html",
|
||||||
|
".m3u8": "audio/mpegurl",
|
||||||
".afl": "video/animaflex",
|
".afl": "video/animaflex",
|
||||||
".ai": "application/postscript",
|
".ai": "application/postscript",
|
||||||
".aif": "audio/aiff",
|
".aif": "audio/aiff",
|
||||||
|
Loading…
Reference in New Issue
Block a user