rename ServerManagerFromContext from ExtractServerManager
This commit is contained in:
parent
abeb9655f9
commit
c9c949a091
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user