Fix details fetching for a single server instance
This commit is contained in:
parent
4c3b497652
commit
d4b63bef39
|
@ -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(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user