Browse Source

Merge branch 'fix_error_code'

pull/176/head
Jianghai He 4 years ago
parent
commit
f1f82c14dd
  1. 7
      protocol/api/api.go

7
protocol/api/api.go

@ -248,7 +248,6 @@ func (s *Server) handlePull(w http.ResponseWriter, req *http.Request) {
delete(s.session, keyString) delete(s.session, keyString)
retString = fmt.Sprintf("<h1>pull url stop %s ok</h1></br>", url) retString = fmt.Sprintf("<h1>pull url stop %s ok</h1></br>", url)
res.Status = 400
res.Data = retString res.Data = retString
log.Debugf("pull stop return %s", retString) log.Debugf("pull stop return %s", retString)
} else { } else {
@ -257,11 +256,12 @@ func (s *Server) handlePull(w http.ResponseWriter, req *http.Request) {
err = pullRtmprelay.Start() err = pullRtmprelay.Start()
if err != nil { if err != nil {
retString = fmt.Sprintf("pull error=%v", err) retString = fmt.Sprintf("pull error=%v", err)
res.Status = 400
} else { } else {
s.session[keyString] = pullRtmprelay s.session[keyString] = pullRtmprelay
retString = fmt.Sprintf("<h1>pull url start %s ok</h1></br>", url) retString = fmt.Sprintf("<h1>pull url start %s ok</h1></br>", url)
} }
res.Status = 400
res.Data = retString res.Data = retString
log.Debugf("pull start return %s", retString) log.Debugf("pull start return %s", retString)
} }
@ -292,6 +292,7 @@ func (s *Server) handlePush(w http.ResponseWriter, req *http.Request) {
log.Debugf("control push: oper=%v, app=%v, name=%v, url=%v", oper, app, name, url) log.Debugf("control push: oper=%v, app=%v, name=%v, url=%v", oper, app, name, url)
if (len(app) <= 0) || (len(name) <= 0) || (len(url) <= 0) { if (len(app) <= 0) || (len(name) <= 0) || (len(url) <= 0) {
res.Status = 400
res.Data = "control push parameter error, please check them." res.Data = "control push parameter error, please check them."
return return
} }
@ -304,6 +305,7 @@ func (s *Server) handlePush(w http.ResponseWriter, req *http.Request) {
pushRtmprelay, found := s.session[keyString] pushRtmprelay, found := s.session[keyString]
if !found { if !found {
retString = fmt.Sprintf("<h1>session key[%s] not exist, please check it again.</h1>", keyString) retString = fmt.Sprintf("<h1>session key[%s] not exist, please check it again.</h1>", keyString)
res.Status = 400
res.Data = retString res.Data = retString
return return
} }
@ -320,6 +322,7 @@ func (s *Server) handlePush(w http.ResponseWriter, req *http.Request) {
err = pushRtmprelay.Start() err = pushRtmprelay.Start()
if err != nil { if err != nil {
retString = fmt.Sprintf("push error=%v", err) retString = fmt.Sprintf("push error=%v", err)
res.Status = 400
} else { } else {
retString = fmt.Sprintf("<h1>push url start %s ok</h1></br>", url) retString = fmt.Sprintf("<h1>push url start %s ok</h1></br>", url)
s.session[keyString] = pushRtmprelay s.session[keyString] = pushRtmprelay

Loading…
Cancel
Save