PLT-6474: Server: Add elasticsearch/test endpoint to API. (#6792)

Этот коммит содержится в:
George Goldberg
2017-06-29 22:40:14 +01:00
коммит произвёл Joram Wilander
родитель a4f363a50b
Коммит f2898927f1
7 изменённых файлов: 106 добавлений и 0 удалений

33
api4/elasticsearch.go Обычный файл
Просмотреть файл

@@ -0,0 +1,33 @@
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package api4
import (
"net/http"
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/app"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
)
func InitElasticsearch() {
l4g.Debug(utils.T("api.elasticsearch.init.debug"))
BaseRoutes.Elasticsearch.Handle("/test", ApiSessionRequired(testElasticsearch)).Methods("POST")
}
func testElasticsearch(c *Context, w http.ResponseWriter, r *http.Request) {
if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
c.SetPermissionError(model.PERMISSION_MANAGE_SYSTEM)
return
}
if err := app.TestElasticsearch(); err != nil {
c.Err = err
return
}
ReturnStatusOK(w)
}