wings/router/middleware.go

26 lines
801 B
Go
Raw Normal View History

2020-04-06 01:00:33 +00:00
package router
import (
"github.com/gin-gonic/gin"
2021-01-16 19:19:33 +00:00
"github.com/pterodactyl/wings/router/middleware"
2020-04-06 01:00:33 +00:00
"github.com/pterodactyl/wings/server"
)
2021-01-16 19:19:33 +00:00
// GetServer is a helper function to fetch a server out of the servers
// collection stored in memory. This function should not be used in new
// controllers, prefer ExtractServer where possible.
// Deprecated
func GetServer(uuid string) *server.Server {
2020-04-06 01:00:33 +00:00
return server.GetServers().Find(func(s *server.Server) bool {
2020-07-20 00:53:41 +00:00
return uuid == s.Id()
2020-04-06 01:00:33 +00:00
})
}
2021-01-16 19:19:33 +00:00
// ExtractServer returns the server instance from the gin context. If there is
// no server set in the context (e.g. calling from a controller not protected by
// ServerExists) this function will panic.
// Deprecated
2020-12-16 04:19:09 +00:00
func ExtractServer(c *gin.Context) *server.Server {
2021-01-16 19:19:33 +00:00
return middleware.ExtractServer(c)
}