Files
ArmA-3-web-server/backend/internal/api/router.go
T
MrFastwind 6f3175ac9a
CI / build (push) Successful in 1m44s
feat: add Wine Z: path prefix for Windows platform on Linux host
- Add winePath helper that prepends Z: when platform is windows on Linux
- Thread platform through buildModPath, buildAutoArgs, and Start()
- Apply Z: prefix to -config=, -mod=, -profiles=, and %command% binary paths
- Add tests for winePath, buildAutoArgs, and buildModPath with platform param
- Fix formatting across services package with gofmt
- Include all prior bug fixes from this branch
2026-07-24 03:57:51 +02:00

100 lines
3.0 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
scheduler *services.Scheduler
streamer *services.LogStreamer
dataDir string
serverfileDir string
modsDir string
cfgDir string
profilesDir string
frontendServed bool
}
func New(
settings *services.SettingsManager,
configs *services.ConfigManager,
modlists *services.ModlistManager,
process *services.ProcessManager,
steamcmd *services.SteamCmdManager,
scheduler *services.Scheduler,
streamer *services.LogStreamer,
dataDir, serverfileDir, modsDir, cfgDir, profilesDir string,
frontendServed bool,
) *Handler {
return &Handler{
settings: settings,
configs: configs,
modlists: modlists,
process: process,
steamcmd: steamcmd,
scheduler: scheduler,
streamer: streamer,
dataDir: dataDir,
serverfileDir: serverfileDir,
modsDir: modsDir,
cfgDir: cfgDir,
profilesDir: profilesDir,
frontendServed: frontendServed,
}
}
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/health", h.Health)
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)
api.GET("/modlists/:id/export", h.ExportModlist)
api.GET("/mods", h.ListMods)
api.DELETE("/mods", h.DeleteMod)
api.POST("/mods/cleanup", h.CleanupMods)
}
r.GET("/ws/server/logs", h.StreamLogs)
r.GET("/ws/steamcmd/logs", h.StreamSteamCMDLogs)
r.GET("/ws/server/rpt", h.StreamRPTLogs)
}