From d4b63bef396882ad4089a4645a5a809bc891291a Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 3 Apr 2021 13:15:11 -0700 Subject: [PATCH] Fix details fetching for a single server instance --- router/router_server.go | 7 +++---- router/router_system.go | 16 +++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/router/router_server.go b/router/router_server.go index a275845..17d14b3 100644 --- a/router/router_server.go +++ b/router/router_server.go @@ -24,10 +24,9 @@ type serverProcData struct { // Returns a single server from the collection of servers. func getServer(c *gin.Context) { s := ExtractServer(c) - - c.JSON(http.StatusOK, serverProcData{ - ResourceUsage: s.Proc(), - Suspended: s.IsSuspended(), + c.JSON(http.StatusOK, ServerJsonResponse{ + Configuration: s.Config(), + Resources: s.Proc(), }) } diff --git a/router/router_system.go b/router/router_system.go index 58ff70c..28ee144 100644 --- a/router/router_system.go +++ b/router/router_system.go @@ -14,6 +14,13 @@ import ( "github.com/pterodactyl/wings/system" ) +// ServerJsonResponse is a type returned when requesting details about a single +// server instance on Wings. +type ServerJsonResponse struct { + *server.Configuration + Resources server.ResourceUsage `json:"resources"` +} + // Returns information about the system that wings is running on. func getSystemInformation(c *gin.Context) { i, err := system.GetSystemInformation() @@ -29,15 +36,10 @@ func getSystemInformation(c *gin.Context) { // Returns all of the servers that are registered and configured correctly on // this wings instance. func getAllServers(c *gin.Context) { - type serverItem struct { - *server.Configuration - Resources server.ResourceUsage `json:"resources"` - } - servers := middleware.ExtractManager(c).All() - out := make([]serverItem, len(servers), len(servers)) + out := make([]ServerJsonResponse, len(servers), len(servers)) for i, v := range servers { - out[i] = serverItem{ + out[i] = ServerJsonResponse{ Configuration: v.Config(), Resources: v.Proc(), }