From 3da84454ee875ce4f1a19356c8cf18315b074e6c Mon Sep 17 00:00:00 2001 From: George Shaw Date: Mon, 13 Nov 2017 16:10:02 -0600 Subject: [PATCH] issue #63 --- pkg/api/server/README.md | 27 +++++++++++++++++---------- pkg/api/server/maintenance.go | 2 ++ pkg/api/server/restart.go | 2 ++ pkg/api/server/shutdown.go | 2 ++ pkg/api/server/start.go | 1 + pkg/api/server/status.go | 2 ++ 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/pkg/api/server/README.md b/pkg/api/server/README.md index e7a4062..ae210f1 100644 --- a/pkg/api/server/README.md +++ b/pkg/api/server/README.md @@ -6,8 +6,11 @@ Relative API Path: api/server/status Request: N/A -Response(): - N/A +Response(200, 405): + "0" - OFF, + "1" - ON, + "2" - "MAINTENANCE", + "3" - "RESTARTING" */ func Status(res http.ResponseWriter, req *http.Request) bool {} @@ -16,27 +19,31 @@ Relative API Path: api/server/start Request: N/A -Response(): +Response(204, 405, 409): N/A */ func Start(res http.ResponseWriter, req *http.Request) bool {} /* Relative API Path: - api/server/Shutdown + api/server/shutdown Request: - N/A -Response(): + { + "graceful": boolean + } +Response(204, 404, 405): N/A */ func Shutdown(res http.ResponseWriter, req *http.Request) bool {} /* Relative API Path: - api/server/Restart + api/server/restart Request: - N/A -Response(): + { + "graceful": boolean + } +Response(204, 404, 405): N/A */ func Restart(res http.ResponseWriter, req *http.Request) bool {} @@ -46,7 +53,7 @@ Relative API Path: api/server/maintenance Request: N/A -Response(): +Response(204, 405): N/A */ func Maintenance(res http.ResponseWriter, req *http.Request) bool {} diff --git a/pkg/api/server/maintenance.go b/pkg/api/server/maintenance.go index 40eb7f8..d09327f 100644 --- a/pkg/api/server/maintenance.go +++ b/pkg/api/server/maintenance.go @@ -7,6 +7,8 @@ import ( "github.com/Ennovar/gPanel/pkg/public" ) +// Maintenance function is called from /api/server/maintenance and will place the public server into +// maintenance mode. func Maintenance(res http.ResponseWriter, req *http.Request, publicServer *public.Controller) bool { if req.Method != "UPDATE" { http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) diff --git a/pkg/api/server/restart.go b/pkg/api/server/restart.go index 9098c07..6e553ad 100644 --- a/pkg/api/server/restart.go +++ b/pkg/api/server/restart.go @@ -8,6 +8,8 @@ import ( "github.com/Ennovar/gPanel/pkg/public" ) +// Restart function is called from /api/server/restart and will attempt to shutdown, either gracefully +// or not gracefully (contingent on request data), and then turn back on the public server. func Restart(res http.ResponseWriter, req *http.Request, publicServer *public.Controller) bool { if req.Method != "UPDATE" { http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) diff --git a/pkg/api/server/shutdown.go b/pkg/api/server/shutdown.go index a14b880..3d6224d 100644 --- a/pkg/api/server/shutdown.go +++ b/pkg/api/server/shutdown.go @@ -8,6 +8,8 @@ import ( "github.com/Ennovar/gPanel/pkg/public" ) +// Shutdown function is called from /api/server/shutdown and will attempt to shutdown, either gracefully +// or not gracefully (contingent on request data). func Shutdown(res http.ResponseWriter, req *http.Request, publicServer *public.Controller) bool { if req.Method != "UPDATE" { http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) diff --git a/pkg/api/server/start.go b/pkg/api/server/start.go index 1b5c1b4..6ca1d17 100644 --- a/pkg/api/server/start.go +++ b/pkg/api/server/start.go @@ -7,6 +7,7 @@ import ( "github.com/Ennovar/gPanel/pkg/public" ) +// Start function is called from /api/server/start and turn the public server on. func Start(res http.ResponseWriter, req *http.Request, publicServer *public.Controller) bool { if req.Method != "UPDATE" { http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed) diff --git a/pkg/api/server/status.go b/pkg/api/server/status.go index fba7927..1212937 100644 --- a/pkg/api/server/status.go +++ b/pkg/api/server/status.go @@ -8,6 +8,8 @@ import ( "github.com/Ennovar/gPanel/pkg/public" ) +// Status function is called from api/server/status and will return the current status of +// the public server. func Status(res http.ResponseWriter, req *http.Request, publicServer *public.Controller) bool { if req.Method != "GET" { http.Error(res, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)