Move WebSocket API to it's own package and add websocket v4 endpoint (#5881)

Этот коммит содержится в:
Joram Wilander
2017-03-28 04:58:19 -04:00
коммит произвёл George Goldberg
родитель ca8b8d1245
Коммит daca0d93f6
22 изменённых файлов: 370 добавлений и 96 удалений

Просмотреть файл

@@ -10,7 +10,6 @@ import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
)
@@ -21,8 +20,6 @@ func InitGeneral() {
BaseRoutes.General.Handle("/client_props", ApiAppHandler(getClientConfig)).Methods("GET")
BaseRoutes.General.Handle("/log_client", ApiAppHandler(logClient)).Methods("POST")
BaseRoutes.General.Handle("/ping", ApiAppHandler(ping)).Methods("GET")
app.Srv.WebSocketRouter.Handle("ping", ApiWebSocketHandler(webSocketPing))
}
func getClientConfig(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -72,13 +69,3 @@ func ping(c *Context, w http.ResponseWriter, r *http.Request) {
m["server_time"] = fmt.Sprintf("%v", model.GetMillis())
w.Write([]byte(model.MapToJson(m)))
}
func webSocketPing(req *model.WebSocketRequest) (map[string]interface{}, *model.AppError) {
data := map[string]interface{}{}
data["text"] = "pong"
data["version"] = model.CurrentVersion
data["server_time"] = model.GetMillis()
data["node_id"] = ""
return data, nil
}