MM-18827 - Can not use api/v4/websocket with trailing slash (#12931)
Этот коммит содержится в:
коммит произвёл
Saturnino Abril
родитель
7a665aacdd
Коммит
4cc2973483
@@ -12,7 +12,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (api *API) InitWebSocket() {
|
func (api *API) InitWebSocket() {
|
||||||
api.BaseRoutes.ApiRoot.Handle("/websocket", api.ApiHandlerTrustRequester(connectWebSocket)).Methods("GET")
|
// Optionally supports a trailing slash
|
||||||
|
api.BaseRoutes.ApiRoot.Handle("/{websocket:websocket(?:\\/)?}", api.ApiHandlerTrustRequester(connectWebSocket)).Methods("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) {
|
func connectWebSocket(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -66,6 +66,15 @@ func TestWebSocket(t *testing.T) {
|
|||||||
require.Equal(t, resp.Error.DetailedError, "", "detailed error not cleared")
|
require.Equal(t, resp.Error.DetailedError, "", "detailed error not cleared")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWebSocketTrailingSlash(t *testing.T) {
|
||||||
|
th := Setup().InitBasic()
|
||||||
|
defer th.TearDown()
|
||||||
|
|
||||||
|
url := fmt.Sprintf("ws://localhost:%v", th.App.Srv.ListenAddr.Port)
|
||||||
|
_, _, err := websocket.DefaultDialer.Dial(url+model.API_URL_SUFFIX+"/websocket/", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestWebSocketEvent(t *testing.T) {
|
func TestWebSocketEvent(t *testing.T) {
|
||||||
th := Setup().InitBasic()
|
th := Setup().InitBasic()
|
||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user