Merge pull request #609 in YUNIONIO/onecloud from ~ZHOUYOUSONG/onecloud:bugfix/yousong-general-server-error to release/2.4.0

* commit '3213cf047a99c57965bc983e02e8f47f902b25fd':
  webconsole: 修正httperrors.GeneralServerError调用
  webconsole: 改进protocol检查
  httperrors: 修正InternalServerError调用
This commit is contained in:
李泽玺
2018-11-30 11:09:17 +08:00
2 changed files with 5 additions and 6 deletions
+1 -2
View File
@@ -1,7 +1,6 @@
package httperrors
import (
"fmt"
"net/http"
"yunion.io/x/jsonutils"
@@ -31,7 +30,7 @@ func GeneralServerError(w http.ResponseWriter, e error) {
if ok {
JsonClientError(w, je)
} else {
InternalServerError(w, fmt.Sprintf("%s", e))
InternalServerError(w, "%s", e)
}
}
+4 -4
View File
@@ -5,7 +5,6 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/log"
"yunion.io/x/pkg/util/sets"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/webconsole/session"
@@ -37,13 +36,14 @@ func (s *ConnectionServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
var srv http.Handler
protocol := sessionObj.GetProtocol()
if sets.NewString(session.VNC, session.SPICE, session.WMKS).Has(protocol) {
switch protocol {
case session.VNC, session.SPICE, session.WMKS:
srv, err = NewWebsockifyServer(sessionObj)
} else {
default:
srv, err = NewTTYServer(sessionObj)
}
if err != nil {
httperrors.GeneralServerError(w, "New server error: %v", err)
httperrors.GeneralServerError(w, err)
return
}
srv.ServeHTTP(w, req)