86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
package api
|
|
|
|
import (
|
|
"arma3-web-server/internal/services"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type Handler struct {
|
|
settings *services.SettingsManager
|
|
configs *services.ConfigManager
|
|
modlists *services.ModlistManager
|
|
process *services.ProcessManager
|
|
steamcmd *services.SteamCmdManager
|
|
streamer *services.LogStreamer
|
|
serverfileDir string
|
|
modsDir string
|
|
cfgDir string
|
|
profilesDir string
|
|
}
|
|
|
|
func New(
|
|
settings *services.SettingsManager,
|
|
configs *services.ConfigManager,
|
|
modlists *services.ModlistManager,
|
|
process *services.ProcessManager,
|
|
steamcmd *services.SteamCmdManager,
|
|
streamer *services.LogStreamer,
|
|
serverfileDir, modsDir, cfgDir, profilesDir string,
|
|
) *Handler {
|
|
return &Handler{
|
|
settings: settings,
|
|
configs: configs,
|
|
modlists: modlists,
|
|
process: process,
|
|
steamcmd: steamcmd,
|
|
streamer: streamer,
|
|
serverfileDir: serverfileDir,
|
|
modsDir: modsDir,
|
|
cfgDir: cfgDir,
|
|
profilesDir: profilesDir,
|
|
}
|
|
}
|
|
|
|
func (h *Handler) SetupRoutes(r *gin.Engine) {
|
|
api := r.Group("/api")
|
|
{
|
|
api.GET("/server/settings", h.GetSettings)
|
|
api.PUT("/server/settings", h.UpdateSettings)
|
|
api.POST("/server/start", h.StartServer)
|
|
api.POST("/server/stop", h.StopServer)
|
|
api.POST("/server/restart", h.RestartServer)
|
|
api.GET("/server/status", h.ServerStatus)
|
|
api.GET("/server/steamcmd", h.SteamCMDSettings)
|
|
api.POST("/server/steamcmd/update-game", h.SteamCMDUpdateGame)
|
|
api.POST("/server/steamcmd/download-mod", h.SteamCMDDownloadMod)
|
|
api.GET("/server/steamcmd/status", h.SteamCMDStatus)
|
|
api.GET("/server/paths", h.ServerPaths)
|
|
|
|
api.GET("/server/logs", h.ListLogs)
|
|
api.GET("/server/logs/:file", h.GetLog)
|
|
|
|
api.GET("/configs", h.ListConfigs)
|
|
api.POST("/configs", h.CreateConfig)
|
|
api.GET("/configs/:name", h.GetConfig)
|
|
api.PUT("/configs/:name", h.UpdateConfig)
|
|
api.DELETE("/configs/:name", h.DeleteConfig)
|
|
api.POST("/configs/:name/duplicate", h.DuplicateConfig)
|
|
|
|
api.GET("/modlists", h.ListModlists)
|
|
api.POST("/modlists", h.CreateModlist)
|
|
api.GET("/modlists/:id", h.GetModlist)
|
|
api.PUT("/modlists/:id", h.UpdateModlist)
|
|
api.DELETE("/modlists/:id", h.DeleteModlist)
|
|
api.POST("/modlists/:id/duplicate", h.DuplicateModlist)
|
|
api.POST("/modlists/import", h.ImportModlist)
|
|
api.GET("/modlists/:id/check", h.CheckModlistMods)
|
|
api.POST("/modlists/:id/download-missing", h.DownloadMissingMods)
|
|
api.POST("/modlists/:id/update-all", h.UpdateAllMods)
|
|
}
|
|
|
|
r.GET("/ws/server/logs", h.StreamLogs)
|
|
r.GET("/ws/steamcmd/logs", h.StreamSteamCMDLogs)
|
|
r.GET("/ws/server/rpt", h.StreamRPTLogs)
|
|
}
|