1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-07-15 23:54:29 +02:00

[GH-3410] Healthcheck Endpoint with Server Metadata (#4151)

* add ping endpoint and tests

* remove unnecessary newlines

* fix: invalid Swagger YAML comment blocks

* refactor and add 'suite' SKU

* generate swagger docs

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Paul Esch-Laurent <paul.esch-laurent@mattermost.com>
This commit is contained in:
Benjamin Masters
2022-11-14 14:37:06 -05:00
committed by GitHub
parent a8bafb35c9
commit 0cd4257ebc
13 changed files with 3373 additions and 1181 deletions

View File

@ -1,6 +1,7 @@
package api
import (
"encoding/json"
"net/http"
"github.com/gorilla/mux"
@ -9,6 +10,7 @@ import (
func (a *API) registerSystemRoutes(r *mux.Router) {
// System APIs
r.HandleFunc("/hello", a.handleHello).Methods("GET")
r.HandleFunc("/ping", a.handlePing).Methods("GET")
}
func (a *API) handleHello(w http.ResponseWriter, r *http.Request) {
@ -24,3 +26,32 @@ func (a *API) handleHello(w http.ResponseWriter, r *http.Request) {
// description: success
stringResponse(w, "Hello")
}
func (a *API) handlePing(w http.ResponseWriter, r *http.Request) {
// swagger:operation GET /ping ping
//
// Responds with server metadata if the web service is running.
//
// ---
// produces:
// - application/json
// responses:
// '200':
// description: success
serverMetadata := a.app.GetServerMetadata()
if a.singleUserToken != "" {
serverMetadata.SKU = "personal_desktop"
}
if serverMetadata.Edition == "plugin" {
serverMetadata.SKU = "suite"
}
bytes, err := json.Marshal(serverMetadata)
if err != nil {
a.errorResponse(w, r, err)
}
jsonStringResponse(w, 200, string(bytes))
}