File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,13 @@ type Status struct {
5959 Language string `json:"language"`
6060}
6161
62- func (s * StatusAPI ) get (minimal bool ) Status {
62+ func (s * StatusAPI ) get (isDetailed bool ) Status {
6363 status := Status {
6464 DocumentationURL : types .GetEnvString (types .ENV_DOCUMENTATION_URL ),
6565 }
6666 status .MetricsDBDisabled = types .GetEnvBool (types .ENV_METRIC_DB_DISABLED )
6767
68- if ! minimal {
68+ if isDetailed {
6969 hostname , err := os .Hostname ()
7070 if err != nil {
7171 s .logger .Error ("error on getting hostname" , zap .Error (err ))
@@ -96,12 +96,12 @@ func (s *StatusAPI) get(minimal bool) Status {
9696
9797// Get returns status with all fields
9898func (s * StatusAPI ) Get () Status {
99- return s .get (false )
99+ return s .get (true )
100100}
101101
102102// GetMinimal returns limited fields, can be used under status rest api (login not required)
103103func (s * StatusAPI ) GetMinimal () Status {
104- return s .get (true )
104+ return s .get (false )
105105}
106106
107107// docker creates a .dockerenv file at the root of the directory tree inside the container.
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212func (h * Routes ) registerStatusRoutes () {
1313 h .router .HandleFunc ("/api/version" , h .versionData ).Methods (http .MethodGet )
1414 h .router .HandleFunc ("/api/status" , h .status ).Methods (http .MethodGet )
15+ h .router .HandleFunc ("/api/server/status" , h .statusDetailed ).Methods (http .MethodGet ) // provides detailed status, available with valid auth
1516}
1617
1718func (h * Routes ) status (w http.ResponseWriter , r * http.Request ) {
@@ -26,6 +27,18 @@ func (h *Routes) status(w http.ResponseWriter, r *http.Request) {
2627 handlerUtils .WriteResponse (w , od )
2728}
2829
30+ func (h * Routes ) statusDetailed (w http.ResponseWriter , r * http.Request ) {
31+ w .Header ().Set ("Content-Type" , "application/json" )
32+
33+ status := h .api .Status ().Get ()
34+ od , err := json .Marshal (& status )
35+ if err != nil {
36+ http .Error (w , err .Error (), http .StatusInternalServerError )
37+ return
38+ }
39+ handlerUtils .WriteResponse (w , od )
40+ }
41+
2942func (h * Routes ) versionData (w http.ResponseWriter , r * http.Request ) {
3043 w .Header ().Set ("Content-Type" , "application/json" )
3144 v := version .Get ()
You can’t perform that action at this time.
0 commit comments