This commit is contained in:
Liang Ding 2019-05-16 18:10:44 +08:00
parent e97ce75b92
commit 7deb7c60e5
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
4 changed files with 32 additions and 15 deletions

View File

@ -174,7 +174,7 @@ func main() {
http.HandleFunc(conf.Wide.Context+"/playground/save", handlerWrapper(playground.SaveHandler))
http.HandleFunc(conf.Wide.Context+"/playground/short-url", handlerWrapper(playground.ShortURLHandler))
http.HandleFunc(conf.Wide.Context+"/playground/build", handlerWrapper(playground.BuildHandler))
http.HandleFunc(conf.Wide.Context+"/playground/run", handlerWrapper(playground.RunHandler))
http.HandleFunc(conf.Wide.Context+"/playground/run", handlerWrapper(output.RunHandler))
http.HandleFunc(conf.Wide.Context+"/playground/stop", handlerWrapper(playground.StopHandler))
http.HandleFunc(conf.Wide.Context+"/playground/autocomplete", handlerWrapper(playground.AutocompleteHandler))

View File

@ -188,6 +188,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
err = wsChannel.WriteJSON(&channelRet)
if nil != err {
logger.Warn(err)
break
}

View File

@ -111,13 +111,17 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
go func() {
defer util.Recover()
outScanner := bufio.NewScanner(outReader)
for outScanner.Scan() {
oneRuneStr := outScanner.Text()
for {
r, _, err := outReader.ReadRune()
if nil != err {
break
}
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
channelRet["cmd"] = "run"
channelRet["output"] = oneRuneStr + "\n"
channelRet["output"] = oneRuneStr
wsChannel := session.OutputWS[sid]
if nil != wsChannel {
wsChannel.WriteJSON(&channelRet)
@ -126,9 +130,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
}
}()
errScanner := bufio.NewScanner(errReader)
for errScanner.Scan() {
oneRuneStr := errScanner.Text()
for {
r, _, err := errReader.ReadRune()
if nil != err {
break
}
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
channelRet["cmd"] = "run"

View File

@ -123,13 +123,17 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
go func() {
defer util.Recover()
outScanner := bufio.NewScanner(outReader)
for outScanner.Scan() {
oneRuneStr := outScanner.Text()
for {
r, _, err := outReader.ReadRune()
if nil != err {
break
}
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
channelRet["cmd"] = "run"
channelRet["output"] = oneRuneStr + "\n"
channelRet["output"] = oneRuneStr
wsChannel := session.OutputWS[sid]
if nil != wsChannel {
wsChannel.WriteJSON(&channelRet)
@ -138,9 +142,13 @@ func RunHandler(w http.ResponseWriter, r *http.Request) {
}
}()
errScanner := bufio.NewScanner(errReader)
for errScanner.Scan() {
oneRuneStr := errScanner.Text()
for {
r, _, err := errReader.ReadRune()
if nil != err {
break
}
oneRuneStr := string(r)
oneRuneStr = strings.Replace(oneRuneStr, "<", "&lt;", -1)
oneRuneStr = strings.Replace(oneRuneStr, ">", "&gt;", -1)
channelRet["cmd"] = "run"