add trial end date to server status api

This commit is contained in:
abhishek9686
2024-01-20 01:30:09 +05:30
parent e390398e8c
commit 7a39ef3e4e
3 changed files with 15 additions and 39 deletions

View File

@@ -5,6 +5,7 @@ import (
"net/http"
"strings"
"syscall"
"time"
"github.com/gorilla/mux"
"golang.org/x/exp/slog"
@@ -109,22 +110,24 @@ func getUsage(w http.ResponseWriter, _ *http.Request) {
// 200: serverConfigResponse
func getStatus(w http.ResponseWriter, r *http.Request) {
type status struct {
DB bool `json:"db_connected"`
Broker bool `json:"broker_connected"`
LicenseError string `json:"license_error"`
IsPro bool `json:"is_pro"`
DB bool `json:"db_connected"`
Broker bool `json:"broker_connected"`
LicenseError string `json:"license_error"`
IsPro bool `json:"is_pro"`
TrialEndDate time.Time `json:"trial_end_date"`
}
licenseErr := ""
if servercfg.ErrLicenseValidation != nil {
licenseErr = servercfg.ErrLicenseValidation.Error()
}
trialEndDate, _ := logic.GetTrialEndDate()
currentServerStatus := status{
DB: database.IsConnected(),
Broker: mq.IsConnected(),
LicenseError: licenseErr,
IsPro: servercfg.IsPro,
TrialEndDate: trialEndDate,
}
w.Header().Set("Content-Type", "application/json")