|
|
@@ -10,6 +10,7 @@ import ( |
|
|
|
"regexp" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"github.com/Sirupsen/logrus" |
|
|
|
"github.com/goanywhere/env" |
|
|
|
) |
|
|
|
|
|
|
@@ -21,6 +22,7 @@ type writer struct { |
|
|
|
func (self *writer) addJavaScript(data []byte) []byte { |
|
|
|
javascript := fmt.Sprintf(`<script src="//%s%s"></script> |
|
|
|
</head>`, self.host, URL.JavaScript) |
|
|
|
logrus.Infof("JS: %s", javascript) |
|
|
|
return regexp.MustCompile(`</head>`).ReplaceAll(data, []byte(javascript)) |
|
|
|
} |
|
|
|
|
|
|
@@ -66,7 +68,7 @@ func (self *writer) Write(data []byte) (size int, e error) { |
|
|
|
|
|
|
|
func Middleware(next http.Handler) http.Handler { |
|
|
|
// ONLY run this under debug mode. |
|
|
|
if !env.Bool("DEBUG", true) { |
|
|
|
if !env.Bool("DEBUG") { |
|
|
|
return next |
|
|
|
} |
|
|
|
Start() |