From c9c949a09163296a87d700d456611b50df840067 Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Sun, 10 Jan 2021 02:18:02 +0000 Subject: [PATCH] rename ServerManagerFromContext from ExtractServerManager --- router/middleware.go | 2 +- router/router_download.go | 4 ++-- router/router_server.go | 2 +- router/router_server_files.go | 2 +- router/router_server_ws.go | 2 +- router/router_system.go | 4 ++-- router/router_transfer.go | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/router/middleware.go b/router/middleware.go index cb24e82..f2aff64 100644 --- a/router/middleware.go +++ b/router/middleware.go @@ -100,7 +100,7 @@ func (m *Middleware) WithServerManager() gin.HandlerFunc { } } -func ServerManagerFromContext(c *gin.Context) server.Manager { +func ExtractServerManager(c *gin.Context) server.Manager { if s, ok := c.Get("servermanager"); ok { if srvs, ok := s.(server.Manager); ok { return srvs diff --git a/router/router_download.go b/router/router_download.go index 7ddb6f5..325ce6e 100644 --- a/router/router_download.go +++ b/router/router_download.go @@ -14,7 +14,7 @@ import ( // Handle a download request for a server backup. func getDownloadBackup(c *gin.Context) { - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) token := tokens.BackupPayload{} if err := tokens.ParseToken([]byte(c.Query("token")), &token); err != nil { @@ -59,7 +59,7 @@ func getDownloadBackup(c *gin.Context) { // Handles downloading a specific file for a server. func getDownloadFile(c *gin.Context) { - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) token := tokens.FilePayload{} if err := tokens.ParseToken([]byte(c.Query("token")), &token); err != nil { diff --git a/router/router_server.go b/router/router_server.go index cfeb3d0..8b5ff82 100644 --- a/router/router_server.go +++ b/router/router_server.go @@ -191,7 +191,7 @@ func postServerReinstall(c *gin.Context) { // Deletes a server from the wings daemon and dissociate it's objects. func deleteServer(c *gin.Context) { s := ExtractServer(c) - sm := ServerManagerFromContext(c) + sm := ExtractServerManager(c) // Immediately suspend the server to prevent a user from attempting // to start it while this process is running. diff --git a/router/router_server_files.go b/router/router_server_files.go index 278bce9..38e4e1b 100644 --- a/router/router_server_files.go +++ b/router/router_server_files.go @@ -497,7 +497,7 @@ func postServerChmodFile(c *gin.Context) { } func postServerUploadFiles(c *gin.Context) { - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) token := tokens.UploadPayload{} if err := tokens.ParseToken([]byte(c.Query("token")), &token); err != nil { diff --git a/router/router_server_ws.go b/router/router_server_ws.go index 5597a3e..c65a366 100644 --- a/router/router_server_ws.go +++ b/router/router_server_ws.go @@ -12,7 +12,7 @@ import ( // Upgrades a connection to a websocket and passes events along between. func getServerWebsocket(c *gin.Context) { - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) s := serverManager.Get(c.Param("server")) handler, err := websocket.GetHandler(s, c.Writer, c.Request) if err != nil { diff --git a/router/router_system.go b/router/router_system.go index ee46032..9feb8d2 100644 --- a/router/router_system.go +++ b/router/router_system.go @@ -27,7 +27,7 @@ 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) { - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) c.JSON(http.StatusOK, serverManager.GetAll()) } @@ -52,7 +52,7 @@ func postCreateServer(c *gin.Context) { // Plop that server instance onto the request so that it can be referenced in // requests from here-on out. - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) serverManager.Add(install.Server()) // Begin the installation process in the background to not block the request diff --git a/router/router_transfer.go b/router/router_transfer.go index e487c04..98218ee 100644 --- a/router/router_transfer.go +++ b/router/router_transfer.go @@ -323,7 +323,7 @@ func postTransfer(c *gin.Context) { i.Server().Events().Publish(server.TransferLogsEvent, output) } - serverManager := ServerManagerFromContext(c) + serverManager := ExtractServerManager(c) // Mark the server as transferring to prevent problems later on during the process and // then push the server into the global server collection for this instance.