mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user