From 52963009db74060158285f80cd279b0b3767dab4 Mon Sep 17 00:00:00 2001 From: FlowingSPDG Date: Fri, 21 Jun 2024 22:26:24 +0900 Subject: [PATCH] Update ID generics --- controller.go | 82 ++++++------ match.go | 24 +--- models.go | 310 ++++++++++++++++++++++---------------------- models_test.go | 88 ------------- route/gin/dem.go | 8 +- route/gin/events.go | 70 +++++----- route/gin/match.go | 10 +- route/gin/route.go | 8 +- 8 files changed, 249 insertions(+), 351 deletions(-) delete mode 100644 models_test.go diff --git a/controller.go b/controller.go index c6a2e47..0c4c0c4 100644 --- a/controller.go +++ b/controller.go @@ -6,62 +6,62 @@ import ( ) // Auth Auth interface handles auth -type Auth[TMatchID MatchID] interface { +type Auth interface { EventAuth(ctx context.Context, serverID string, auth string) error - MatchAuth(ctx context.Context, mid TMatchID, auth string) error - CheckDemoAuth(ctx context.Context, mid TMatchID, filename string, mapNumber int, serverID string, auth string) error + MatchAuth(ctx context.Context, mid int, auth string) error + CheckDemoAuth(ctx context.Context, mid int, filename string, mapNumber int, serverID string, auth string) error } // EventHandler EventHandler interface handles read operation by get5 events -type EventHandler[TMatchID MatchID] interface { +type EventHandler interface { Close() error // GET5 Events HandleOnGameStateChanged(ctx context.Context, p OnGameStateChangedPayload) error HandleOnPreLoadMatchConfig(ctx context.Context, p OnPreLoadMatchConfigPayload) error HandleOnLoadMatchConfigFailed(ctx context.Context, p OnLoadMatchConfigFailedPayload) error - HandleOnSeriesInit(ctx context.Context, p OnSeriesInitPayload[TMatchID]) error - HandleOnMapResult(ctx context.Context, p OnMapResultPayload[TMatchID]) error - HandleOnSeriesResult(ctx context.Context, p OnSeriesResultPayload[TMatchID]) error - HandleOnSidePicked(ctx context.Context, p OnSidePickedPayload[TMatchID]) error - HandleOnMapPicked(ctx context.Context, p OnMapPickedPayload[TMatchID]) error - HandleOnMapVetoed(ctx context.Context, p OnMapVetoedPayload[TMatchID]) error - HandleOnBackupRestore(ctx context.Context, p OnBackupRestorePayload[TMatchID]) error - HandleOnDemoFinished(ctx context.Context, p OnDemoFinishedPayload[TMatchID]) error - HandleOnDemoUploadEnded(ctx context.Context, p OnDemoUploadEndedPayload[TMatchID]) error - HandleOnMatchPaused(ctx context.Context, p OnMatchPausedPayload[TMatchID]) error - HandleOnMatchUnpaused(ctx context.Context, p OnMatchUnpausedPayload[TMatchID]) error - HandleOnPauseBegan(ctx context.Context, p OnPauseBeganPayload[TMatchID]) error - HandleOnKnifeRoundStarted(ctx context.Context, p OnKnifeRoundStartedPayload[TMatchID]) error - HandleOnKnifeRoundWon(ctx context.Context, p OnKnifeRoundWonPayload[TMatchID]) error - HandleOnTeamReadyStatusChanged(ctx context.Context, p OnTeamReadyStatusChangedPayload[TMatchID]) error - HandleOnGoingLive(ctx context.Context, p OnGoingLivePayload[TMatchID]) error - HandleOnRoundStart(ctx context.Context, p OnRoundStartPayload[TMatchID]) error - HandleOnRoundEnd(ctx context.Context, p OnRoundEndPayload[TMatchID]) error - HandleOnRoundStatsUpdated(ctx context.Context, p OnRoundStatsUpdatedPayload[TMatchID]) error - HandleOnPlayerBecameMVP(ctx context.Context, p OnPlayerBecameMVPPayload[TMatchID]) error - HandleOnGrenadeThrown(ctx context.Context, p OnGrenadeThrownPayload[TMatchID]) error - HandleOnPlayerDeath(ctx context.Context, p OnPlayerDeathPayload[TMatchID]) error - HandleOnHEGrenadeDetonated(ctx context.Context, p OnHEGrenadeDetonatedPayload[TMatchID]) error - HandleOnMolotovDetonated(ctx context.Context, p OnMolotovDetonatedPayload[TMatchID]) error - HandleOnFlashbangDetonated(ctx context.Context, p OnFlashbangDetonatedPayload[TMatchID]) error - HandleOnSmokeGrenadeDetonated(ctx context.Context, p OnSmokeGrenadeDetonatedPayload[TMatchID]) error - HandleOnDecoyStarted(ctx context.Context, p OnDecoyStartedPayload[TMatchID]) error - HandleOnBombPlanted(ctx context.Context, p OnBombPlantedPayload[TMatchID]) error - HandleOnBombDefused(ctx context.Context, p OnBombDefusedPayload[TMatchID]) error - HandleOnBombExploded(ctx context.Context, p OnBombExplodedPayload[TMatchID]) error - HandleOnPlayerConnected(ctx context.Context, p OnPlayerConnectedPayload[TMatchID]) error - HandleOnPlayerDisconnected(ctx context.Context, p OnPlayerDisconnectedPayload[TMatchID]) error - HandleOnPlayerSay(ctx context.Context, p OnPlayerSayPayload[TMatchID]) error + HandleOnSeriesInit(ctx context.Context, p OnSeriesInitPayload) error + HandleOnMapResult(ctx context.Context, p OnMapResultPayload) error + HandleOnSeriesResult(ctx context.Context, p OnSeriesResultPayload) error + HandleOnSidePicked(ctx context.Context, p OnSidePickedPayload) error + HandleOnMapPicked(ctx context.Context, p OnMapPickedPayload) error + HandleOnMapVetoed(ctx context.Context, p OnMapVetoedPayload) error + HandleOnBackupRestore(ctx context.Context, p OnBackupRestorePayload) error + HandleOnDemoFinished(ctx context.Context, p OnDemoFinishedPayload) error + HandleOnDemoUploadEnded(ctx context.Context, p OnDemoUploadEndedPayload) error + HandleOnMatchPaused(ctx context.Context, p OnMatchPausedPayload) error + HandleOnMatchUnpaused(ctx context.Context, p OnMatchUnpausedPayload) error + HandleOnPauseBegan(ctx context.Context, p OnPauseBeganPayload) error + HandleOnKnifeRoundStarted(ctx context.Context, p OnKnifeRoundStartedPayload) error + HandleOnKnifeRoundWon(ctx context.Context, p OnKnifeRoundWonPayload) error + HandleOnTeamReadyStatusChanged(ctx context.Context, p OnTeamReadyStatusChangedPayload) error + HandleOnGoingLive(ctx context.Context, p OnGoingLivePayload) error + HandleOnRoundStart(ctx context.Context, p OnRoundStartPayload) error + HandleOnRoundEnd(ctx context.Context, p OnRoundEndPayload) error + HandleOnRoundStatsUpdated(ctx context.Context, p OnRoundStatsUpdatedPayload) error + HandleOnPlayerBecameMVP(ctx context.Context, p OnPlayerBecameMVPPayload) error + HandleOnGrenadeThrown(ctx context.Context, p OnGrenadeThrownPayload) error + HandleOnPlayerDeath(ctx context.Context, p OnPlayerDeathPayload) error + HandleOnHEGrenadeDetonated(ctx context.Context, p OnHEGrenadeDetonatedPayload) error + HandleOnMolotovDetonated(ctx context.Context, p OnMolotovDetonatedPayload) error + HandleOnFlashbangDetonated(ctx context.Context, p OnFlashbangDetonatedPayload) error + HandleOnSmokeGrenadeDetonated(ctx context.Context, p OnSmokeGrenadeDetonatedPayload) error + HandleOnDecoyStarted(ctx context.Context, p OnDecoyStartedPayload) error + HandleOnBombPlanted(ctx context.Context, p OnBombPlantedPayload) error + HandleOnBombDefused(ctx context.Context, p OnBombDefusedPayload) error + HandleOnBombExploded(ctx context.Context, p OnBombExplodedPayload) error + HandleOnPlayerConnected(ctx context.Context, p OnPlayerConnectedPayload) error + HandleOnPlayerDisconnected(ctx context.Context, p OnPlayerDisconnectedPayload) error + HandleOnPlayerSay(ctx context.Context, p OnPlayerSayPayload) error } // MatchLoader is for Read Operation(get5_loadmatch_url) -type MatchLoader[TMatchID MatchID] interface { +type MatchLoader interface { // Load respond to get5_loadmatch_url - Load(ctx context.Context, mid TMatchID) (G5Match[TMatchID], error) + Load(ctx context.Context, mid int) (*Match, error) } // DemoUploader is for Demo Upload Operation(get5_dem_upload_url) -type DemoUploader[TMatchID MatchID] interface { - Upload(ctx context.Context, mid TMatchID, filename string, r io.Reader) error // demoファイルの登録処理 +type DemoUploader interface { + Upload(ctx context.Context, mid int, filename string, r io.Reader) error // demoファイルの登録処理 } diff --git a/match.go b/match.go index dd5cb76..dddca86 100644 --- a/match.go +++ b/match.go @@ -4,13 +4,8 @@ package got5 // MatchZy: https://shobhit-pathak.github.io/MatchZy/match_setup/#example // MatchZy(source): https://github.com/shobhit-pathak/MatchZy/blob/ae597e50756f8ed8380e4cbacec4a4c1eb9013da/MatchManagement.cs#L254 -// MatchID currently int only -type MatchID interface { - int -} - -type Match[TmatchID MatchID] struct { - MatchID TmatchID `json:"matchid,omitempty"` // originally string in get5 but MatchZy uses int +type Match struct { + MatchID int `json:"matchid,omitempty"` // originally string in get5 but MatchZy uses int ClinchSeries bool `json:"clinch_series,omitempty"` NumMaps int `json:"num_maps,omitempty"` Wingman bool `json:"wingman,omitempty"` @@ -27,13 +22,9 @@ type Match[TmatchID MatchID] struct { Cvars map[string]string `json:"cvars,omitempty"` } -func (m Match[TMatchID]) ToG5Format() Match[TMatchID] { - return m -} - -func GetDefaultMatchBO1[TMatchID MatchID]() Match[TMatchID] { - return Match[TMatchID]{ - MatchID: *new(TMatchID), +func GetDefaultMatchBO1() Match { + return Match{ + MatchID: 0, ClinchSeries: true, NumMaps: 1, PlayersPerTeam: 5, @@ -65,8 +56,3 @@ type Team struct { Players map[string]string `json:"players,omitempty"` Name string `json:"name,omitempty"` } - -// G5Match 別の構造体にG5Matchインターフェースを実装すれば型が違っても変換してGet5に渡してくれる -type G5Match[TMatchID MatchID] interface { - ToG5Format() Match[TMatchID] -} diff --git a/models.go b/models.go index 61cd58f..58ca36a 100644 --- a/models.go +++ b/models.go @@ -33,10 +33,10 @@ type OnLoadMatchConfigFailedPayload struct { } // OnSeriesInitPayload Fired when a series is started after loading a match config. -type OnSeriesInitPayload[TMatchID comparable] struct { +type OnSeriesInitPayload struct { Event - MatchID TMatchID `json:"matchid"` - NumMaps int `json:"num_maps"` + MatchID int `json:"matchid"` + NumMaps int `json:"num_maps"` Team1 struct { ID string `json:"id"` Name string `json:"name"` @@ -48,9 +48,9 @@ type OnSeriesInitPayload[TMatchID comparable] struct { } // OnMapResultPayload Fired when the map ends. -type OnMapResultPayload[TMatchID comparable] struct { +type OnMapResultPayload struct { Event - MatchID TMatchID `json:"matchid"` + MatchID int `json:"matchid"` MapNumber int `json:"map_number"` Team1 Get5StatsTeam `json:"team1"` Team2 Get5StatsTeam `json:"team2"` @@ -110,141 +110,141 @@ type Get5StatsPlayer struct { } // OnSeriesResultPayload Fired when a series is over. winner indicates team and side 0 if there was no winner in cases of a draw or if the series was forcefully canceled. -type OnSeriesResultPayload[TMatchID comparable] struct { +type OnSeriesResultPayload struct { Event - MatchID TMatchID `json:"matchid"` - Team1SeriesScore int `json:"team1_series_score"` - Team2SeriesScore int `json:"team2_series_score"` - Winner Winner `json:"winner"` - TimeUntilRestore int `json:"time_until_restore"` + MatchID int `json:"matchid"` + Team1SeriesScore int `json:"team1_series_score"` + Team2SeriesScore int `json:"team2_series_score"` + Winner Winner `json:"winner"` + TimeUntilRestore int `json:"time_until_restore"` } // OnSidePickedPayload Fired when a side is picked by a team. -type OnSidePickedPayload[TMatchID comparable] struct { +type OnSidePickedPayload struct { Event - MatchID TMatchID `json:"matchid"` - Team string `json:"team"` - MapName string `json:"map_name"` - Side string `json:"side"` - MapNumber int `json:"map_number"` + MatchID int `json:"matchid"` + Team string `json:"team"` + MapName string `json:"map_name"` + Side string `json:"side"` + MapNumber int `json:"map_number"` } // OnMapPickedPayload Fired when a team picks a map. -type OnMapPickedPayload[TMatchID comparable] struct { +type OnMapPickedPayload struct { Event - MatchID TMatchID `json:"matchid"` - Team string `json:"team"` - MapName string `json:"map_name"` - MapNumber int `json:"map_number"` + MatchID int `json:"matchid"` + Team string `json:"team"` + MapName string `json:"map_name"` + MapNumber int `json:"map_number"` } // OnMapVetoedPayload Fired when a team vetos a map. -type OnMapVetoedPayload[TMatchID comparable] struct { +type OnMapVetoedPayload struct { Event - MatchID TMatchID `json:"matchid"` - Team string `json:"team"` - MapName string `json:"map_name"` + MatchID int `json:"matchid"` + Team string `json:"team"` + MapName string `json:"map_name"` } // OnBackupRestorePayload Fired when a round is restored from a backup. Note that the map and round numbers indicate the round being restored to, not the round the backup was requested during. -type OnBackupRestorePayload[TMatchID comparable] struct { +type OnBackupRestorePayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - Filename string `json:"filename"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + Filename string `json:"filename"` } // OnDemoFinishedPayload Fired when the GOTV recording has ended. This event does not fire if no demo was recorded. -type OnDemoFinishedPayload[TMatchID comparable] struct { +type OnDemoFinishedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - Filename string `json:"filename"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + Filename string `json:"filename"` } // OnDemoUploadEndedPayload Fired when the request to upload a demo ends, regardless if it succeeds or fails. If you upload demos, you should not shut down a server until this event has fired. -type OnDemoUploadEndedPayload[TMatchID comparable] struct { +type OnDemoUploadEndedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - Filename string `json:"filename"` - Success bool `json:"success"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + Filename string `json:"filename"` + Success bool `json:"success"` } // Map Flow // OnMatchPausedPayload Fired when the match is paused. -type OnMatchPausedPayload[TMatchID comparable] struct { +type OnMatchPausedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - Team string `json:"team"` - PauseType string `json:"pause_type"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + Team string `json:"team"` + PauseType string `json:"pause_type"` } // OnMatchUnpausedPayload Fired when the match is unpaused. -type OnMatchUnpausedPayload[TMatchID comparable] struct { +type OnMatchUnpausedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - Team string `json:"team"` - PauseType string `json:"pause_type"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + Team string `json:"team"` + PauseType string `json:"pause_type"` } -type OnPauseBeganPayload[TMatchID comparable] struct { +type OnPauseBeganPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - Team string `json:"team"` - PauseType string `json:"pause_type"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + Team string `json:"team"` + PauseType string `json:"pause_type"` } // OnKnifeRoundStartedPayload Fired when the knife round starts. -type OnKnifeRoundStartedPayload[TMatchID comparable] struct { +type OnKnifeRoundStartedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` } // OnKnifeRoundWonPayload Fired when the knife round is over and the teams have elected to swap or stay. side represents the chosen side of the winning team, not the side that won the knife round. -type OnKnifeRoundWonPayload[TMatchID comparable] struct { +type OnKnifeRoundWonPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - Team string `json:"team"` - Side string `json:"side"` - Swapped bool `json:"swapped"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + Team string `json:"team"` + Side string `json:"side"` + Swapped bool `json:"swapped"` } // OnTeamReadyStatusChangedPayload Fired when a team's ready status changes. -type OnTeamReadyStatusChangedPayload[TMatchID comparable] struct { +type OnTeamReadyStatusChangedPayload struct { Event - MatchID TMatchID `json:"matchid"` - Team *string `json:"team"` // nullable - Ready bool `json:"ready"` - GameState string `json:"game_state"` + MatchID int `json:"matchid"` + Team *string `json:"team"` // nullable + Ready bool `json:"ready"` + GameState string `json:"game_state"` } // OnGoingLivePayload Fired when a map is going live. -type OnGoingLivePayload[TMatchID comparable] struct { +type OnGoingLivePayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` } // OnRoundStartPayload Fired when a round starts (when freezetime begins). -type OnRoundStartPayload[TMatchID comparable] struct { +type OnRoundStartPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` } // OnRoundEndPayload Fired when a round ends - when the result is in; not when the round stops. Game activity can occur after this. -type OnRoundEndPayload[TMatchID comparable] struct { +type OnRoundEndPayload struct { Event - MatchID TMatchID `json:"matchid"` + MatchID int `json:"matchid"` MapNumber int `json:"map_number"` RoundNumber int `json:"round_number"` RoundTime int `json:"round_time"` @@ -261,21 +261,21 @@ type Winner struct { } // OnRoundStatsUpdatedPayload Fired after the stats update on round end. -type OnRoundStatsUpdatedPayload[TMatchID comparable] struct { +type OnRoundStatsUpdatedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` } // OnPlayerBecameMVPPayload Fired when a player is elected the MVP of the round. -type OnPlayerBecameMVPPayload[TMatchID comparable] struct { +type OnPlayerBecameMVPPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - Player Player `json:"player"` - Reason int `json:"reason"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + Player Player `json:"player"` + Reason int `json:"reason"` } // Player player @@ -288,14 +288,14 @@ type Player struct { } // OnGrenadeThrownPayload Fired whenever a grenade is thrown by a player. The weapon property reflects the grenade used. -type OnGrenadeThrownPayload[TMatchID comparable] struct { +type OnGrenadeThrownPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Player Player `json:"player"` - Weapon Weapon `json:"weapon"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Player Player `json:"player"` + Weapon Weapon `json:"weapon"` } // Weapon Weapon @@ -305,9 +305,9 @@ type Weapon struct { } // OnPlayerDeathPayload Fired when a player dies. -type OnPlayerDeathPayload[TMatchID comparable] struct { +type OnPlayerDeathPayload struct { Event - MatchID TMatchID `json:"matchid"` + MatchID int `json:"matchid"` MapNumber int `json:"map_number"` RoundNumber int `json:"round_number"` RoundTime int `json:"round_time"` @@ -342,9 +342,9 @@ type Assist struct { } // OnHEGrenadeDetonatedPayload Fired when an HE grenade detonates. player describes who threw the HE and victims who were affected. weapon is always an HE grenade. -type OnHEGrenadeDetonatedPayload[TMatchID comparable] struct { +type OnHEGrenadeDetonatedPayload struct { Event - MatchID TMatchID `json:"matchid"` + MatchID int `json:"matchid"` MapNumber int `json:"map_number"` RoundNumber int `json:"round_number"` RoundTime int `json:"round_time"` @@ -363,9 +363,9 @@ type Victim struct { } // OnMolotovDetonatedPayload Fired when a molotov grenade expires. player describes who threw the molotov and victims who were affected. weapon is always a molotov grenade. Note that round_time reflects the time at which the grenade detonated (started burning). -type OnMolotovDetonatedPayload[TMatchID comparable] struct { +type OnMolotovDetonatedPayload struct { Event - MatchID TMatchID `json:"matchid"` + MatchID int `json:"matchid"` MapNumber int `json:"map_number"` RoundNumber int `json:"round_number"` RoundTime int `json:"round_time"` @@ -377,9 +377,9 @@ type OnMolotovDetonatedPayload[TMatchID comparable] struct { } // OnFlashbangDetonatedPayload Fired when a flash bang grenade detonates. player describes who threw the flash bang and victims who were affected. weapon is always a flash bang grenade. -type OnFlashbangDetonatedPayload[TMatchID comparable] struct { +type OnFlashbangDetonatedPayload struct { Event - MatchID TMatchID `json:"matchid"` + MatchID int `json:"matchid"` MapNumber int `json:"map_number"` RoundNumber int `json:"round_number"` RoundTime int `json:"round_time"` @@ -389,84 +389,84 @@ type OnFlashbangDetonatedPayload[TMatchID comparable] struct { } // OnSmokeGrenadeDetonatedPayload Fired when an smoke grenade expires. player describes who threw the grenade. weapon is always a smoke grenade. -type OnSmokeGrenadeDetonatedPayload[TMatchID comparable] struct { +type OnSmokeGrenadeDetonatedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Player Player `json:"player"` - Weapon Weapon `json:"weapon"` - ExtinguishedMolotov bool `json:"extinguished_molotov"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Player Player `json:"player"` + Weapon Weapon `json:"weapon"` + ExtinguishedMolotov bool `json:"extinguished_molotov"` } // OnDecoyStartedPayload Fired when a decoy starts making noise. player describes who threw the grenade. weapon is always a decoy grenade. -type OnDecoyStartedPayload[TMatchID comparable] struct { +type OnDecoyStartedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Player Player `json:"player"` - Weapon Weapon `json:"weapon"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Player Player `json:"player"` + Weapon Weapon `json:"weapon"` } // OnBombPlantedPayload Fired when the bomb is planted. player describes who planted the bomb. -type OnBombPlantedPayload[TMatchID comparable] struct { +type OnBombPlantedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Player Player `json:"player"` - Site string `json:"site"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Player Player `json:"player"` + Site string `json:"site"` } // OnBombDefusedPayload Fired when the bomb is defused. player describes who defused the bomb. -type OnBombDefusedPayload[TMatchID comparable] struct { +type OnBombDefusedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Player Player `json:"player"` - Site string `json:"site"` - BombTimeRemaining int `json:"bomb_time_remaining"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Player Player `json:"player"` + Site string `json:"site"` + BombTimeRemaining int `json:"bomb_time_remaining"` } // OnBombExplodedPayload Fired when the bomb explodes. -type OnBombExplodedPayload[TMatchID comparable] struct { +type OnBombExplodedPayload struct { Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Site string `json:"site"` + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Site string `json:"site"` } // OnPlayerConnectedPayload Fired when a player connects to the server. -type OnPlayerConnectedPayload[TMatchID comparable] struct { +type OnPlayerConnectedPayload struct { Event - MatchID TMatchID `json:"matchid"` - Player Player `json:"player"` - IPAddress string `json:"ip_address"` + MatchID int `json:"matchid"` + Player Player `json:"player"` + IPAddress string `json:"ip_address"` } // OnPlayerDisconnectedPayload Fired when a player disconnects from the server. -type OnPlayerDisconnectedPayload[TMatchID comparable] struct { +type OnPlayerDisconnectedPayload struct { Event - MatchID TMatchID `json:"matchid"` - Player Player `json:"player"` + MatchID int `json:"matchid"` + Player Player `json:"player"` } // OnPlayerSayPayload Fired when a player types in chat. -type OnPlayerSayPayload[TMatchID comparable] struct { - Event - MatchID TMatchID `json:"matchid"` - MapNumber int `json:"map_number"` - RoundNumber int `json:"round_number"` - RoundTime int `json:"round_time"` - Player Player `json:"player"` - Command string `json:"command"` - Message string `json:"message"` +type OnPlayerSayPayload struct { + Event + MatchID int `json:"matchid"` + MapNumber int `json:"map_number"` + RoundNumber int `json:"round_number"` + RoundTime int `json:"round_time"` + Player Player `json:"player"` + Command string `json:"command"` + Message string `json:"message"` } diff --git a/models_test.go b/models_test.go deleted file mode 100644 index 6c4e8e2..0000000 --- a/models_test.go +++ /dev/null @@ -1,88 +0,0 @@ -package got5_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - got5 "github.com/FlowingSPDG/Got5" -) - -func TestG5Match(t *testing.T) { - asserts := assert.New(t) - cases := []struct { - title string - input got5.Match[int] - }{ - { - title: "マッチのG5インターフェース変換テスト", - input: got5.Match[int]{ - MatchID: 0, - ClinchSeries: false, - NumMaps: 3, - PlayersPerTeam: 5, - MinPlayersToReady: 10, - MinSpectatorsToReady: 0, - SkipVeto: false, - Spectators: got5.Spectators{}, - Maplist: []string{"de_anubis", "de_nuke", "de_inferno", "de_mirage", "de_vertigo", "de_ancient", "de_overpass"}, - MapSides: []string{"knife"}, - Team1: got5.Team{}, - Team2: got5.Team{}, - Cvars: map[string]string{}, - }, - }, - { - title: "複雑なマッチのパース", - input: got5.Match[int]{ - MatchID: 1234567890, - ClinchSeries: true, - NumMaps: 5, - PlayersPerTeam: 3, - MinPlayersToReady: 8, - MinSpectatorsToReady: 2, - SkipVeto: true, - Spectators: got5.Spectators{ - Players: map[string]string{ - "rjzefl": "flowingspdg", - }, - }, - Maplist: []string{"de_ancient", "de_overpass"}, - MapSides: []string{"knife"}, - Team1: got5.Team{ - Name: "Team1 Test", - Players: map[string]string{ - "fl1": "flowingspdg", - }, - }, - Team2: got5.Team{ - Name: "", - Players: map[string]string{ - "fl2": "flowingspdg", - }, - }, - Cvars: map[string]string{}, - }, - }, - } - - for _, tt := range cases { - t.Run(tt.title, func(t *testing.T) { - asserts.Equal(tt.input.MatchID, tt.input.ToG5Format().MatchID) - asserts.Equal(tt.input.ClinchSeries, tt.input.ToG5Format().ClinchSeries) - asserts.Equal(tt.input.NumMaps, tt.input.ToG5Format().NumMaps) - asserts.Equal(tt.input.PlayersPerTeam, tt.input.ToG5Format().PlayersPerTeam) - asserts.Equal(tt.input.MinPlayersToReady, tt.input.ToG5Format().MinPlayersToReady) - asserts.Equal(tt.input.MinSpectatorsToReady, tt.input.ToG5Format().MinSpectatorsToReady) - asserts.Equal(tt.input.SkipVeto, tt.input.ToG5Format().SkipVeto) - asserts.Equal(tt.input.Spectators, tt.input.ToG5Format().Spectators) - asserts.Equal(tt.input.Maplist, tt.input.ToG5Format().Maplist) - asserts.Equal(tt.input.MapSides, tt.input.ToG5Format().MapSides) - asserts.Equal(tt.input.Team1, tt.input.ToG5Format().Team1) - asserts.Equal(tt.input.Team2, tt.input.ToG5Format().Team2) - asserts.Equal(tt.input.Cvars, tt.input.ToG5Format().Cvars) - }) - } -} - -// DefaultBO1 diff --git a/route/gin/dem.go b/route/gin/dem.go index b9d3c53..7e96a67 100644 --- a/route/gin/dem.go +++ b/route/gin/dem.go @@ -9,7 +9,7 @@ import ( ) // CheckDemoAuth 認証用ハンドラ -func CheckDemoAuth[TMatchID int](auth got5.Auth[TMatchID]) func(c *gin.Context) { +func CheckDemoAuth(auth got5.Auth) func(c *gin.Context) { return func(c *gin.Context) { // Verifyをかける filename := c.GetHeader("Get5-FileName") @@ -34,7 +34,7 @@ func CheckDemoAuth[TMatchID int](auth got5.Auth[TMatchID]) func(c *gin.Context) serverID := c.GetHeader("Get5-ServerId") reqAuth := c.GetHeader("Authorization") - if err := auth.CheckDemoAuth(c, TMatchID(mid), filename, mapNum, serverID, reqAuth); err != nil { + if err := auth.CheckDemoAuth(c, int(mid), filename, mapNum, serverID, reqAuth); err != nil { c.AbortWithError(http.StatusUnauthorized, err) // カスタムエラーを返したい return } @@ -44,7 +44,7 @@ func CheckDemoAuth[TMatchID int](auth got5.Auth[TMatchID]) func(c *gin.Context) // DemoUploadHandler POST CS:GO dem file. // アップロードされたdemファイルを制御するハンドラ -func DemoUploadHandler[TMatchID int](uploader got5.DemoUploader[TMatchID]) func(c *gin.Context) { +func DemoUploadHandler(uploader got5.DemoUploader) func(c *gin.Context) { return (func(c *gin.Context) { // アップロードを実施 @@ -57,7 +57,7 @@ func DemoUploadHandler[TMatchID int](uploader got5.DemoUploader[TMatchID]) func( return } - if err := uploader.Upload(c, TMatchID(mid), filename, c.Request.Body); err != nil { + if err := uploader.Upload(c, int(mid), filename, c.Request.Body); err != nil { c.String(http.StatusInternalServerError, err.Error()) // カスタムエラーを返したい } c.String(http.StatusOK, "OK") diff --git a/route/gin/events.go b/route/gin/events.go index f150fc9..39e87c3 100644 --- a/route/gin/events.go +++ b/route/gin/events.go @@ -22,7 +22,7 @@ func reMarshal(m map[string]any, p any) error { } // OnEventHandler POST on /Get5_OnEvent -func OnEventHandler[TMatchID got5.MatchID](ctrl got5.EventHandler[TMatchID]) func(c *gin.Context) { +func OnEventHandler(ctrl got5.EventHandler) func(c *gin.Context) { return (func(c *gin.Context) { p := make(map[string]any) if err := c.ShouldBindJSON(&p); err != nil { @@ -54,229 +54,229 @@ func OnEventHandler[TMatchID got5.MatchID](ctrl got5.EventHandler[TMatchID]) fun } ctrl.HandleOnLoadMatchConfigFailed(c, ret) case "series_start": - ret := got5.OnSeriesInitPayload[TMatchID]{} + ret := got5.OnSeriesInitPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code } ctrl.HandleOnSeriesInit(c, ret) case "map_result": - ret := got5.OnMapResultPayload[TMatchID]{} + ret := got5.OnMapResultPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code } ctrl.HandleOnMapResult(c, ret) case "series_end": - ret := got5.OnSeriesResultPayload[TMatchID]{} + ret := got5.OnSeriesResultPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnSeriesResult(c, ret) case "side_picked": - ret := got5.OnSidePickedPayload[TMatchID]{} + ret := got5.OnSidePickedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnSidePicked(c, ret) case "map_picked": - ret := got5.OnMapPickedPayload[TMatchID]{} + ret := got5.OnMapPickedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnMapPicked(c, ret) case "map_vetoed": - ret := got5.OnMapVetoedPayload[TMatchID]{} + ret := got5.OnMapVetoedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnMapVetoed(c, ret) case "backup_loaded": - ret := got5.OnBackupRestorePayload[TMatchID]{} + ret := got5.OnBackupRestorePayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnBackupRestore(c, ret) case "demo_finished": - ret := got5.OnDemoFinishedPayload[TMatchID]{} + ret := got5.OnDemoFinishedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnDemoFinished(c, ret) case "demo_upload_ended": - ret := got5.OnDemoUploadEndedPayload[TMatchID]{} + ret := got5.OnDemoUploadEndedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnDemoUploadEnded(c, ret) case "game_paused": - ret := got5.OnMatchPausedPayload[TMatchID]{} + ret := got5.OnMatchPausedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnMatchPaused(c, ret) case "game_unpaused": - ret := got5.OnMatchUnpausedPayload[TMatchID]{} + ret := got5.OnMatchUnpausedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnMatchUnpaused(c, ret) case "pause_began": - ret := got5.OnPauseBeganPayload[TMatchID]{} + ret := got5.OnPauseBeganPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnPauseBegan(c, ret) case "knife_start": - ret := got5.OnKnifeRoundStartedPayload[TMatchID]{} + ret := got5.OnKnifeRoundStartedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnKnifeRoundStarted(c, ret) case "knife_won": - ret := got5.OnKnifeRoundWonPayload[TMatchID]{} + ret := got5.OnKnifeRoundWonPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnKnifeRoundWon(c, ret) case "team_ready_status_changed": - ret := got5.OnTeamReadyStatusChangedPayload[TMatchID]{} + ret := got5.OnTeamReadyStatusChangedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnTeamReadyStatusChanged(c, ret) case "going_live": - ret := got5.OnGoingLivePayload[TMatchID]{} + ret := got5.OnGoingLivePayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnGoingLive(c, ret) case "round_start": - ret := got5.OnRoundStartPayload[TMatchID]{} + ret := got5.OnRoundStartPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnRoundStart(c, ret) case "round_end": - ret := got5.OnRoundEndPayload[TMatchID]{} + ret := got5.OnRoundEndPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnRoundEnd(c, ret) case "stats_updated": - ret := got5.OnRoundStatsUpdatedPayload[TMatchID]{} + ret := got5.OnRoundStatsUpdatedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnRoundStatsUpdated(c, ret) case "round_mvp": - ret := got5.OnPlayerBecameMVPPayload[TMatchID]{} + ret := got5.OnPlayerBecameMVPPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnPlayerBecameMVP(c, ret) case "grenade_thrown": - ret := got5.OnGrenadeThrownPayload[TMatchID]{} + ret := got5.OnGrenadeThrownPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnGrenadeThrown(c, ret) case "player_death": - ret := got5.OnPlayerDeathPayload[TMatchID]{} + ret := got5.OnPlayerDeathPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnPlayerDeath(c, ret) case "hegrenade_detonated": - ret := got5.OnHEGrenadeDetonatedPayload[TMatchID]{} + ret := got5.OnHEGrenadeDetonatedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnHEGrenadeDetonated(c, ret) case "molotov_detonated": - ret := got5.OnMolotovDetonatedPayload[TMatchID]{} + ret := got5.OnMolotovDetonatedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnMolotovDetonated(c, ret) case "flashbang_detonated": - ret := got5.OnFlashbangDetonatedPayload[TMatchID]{} + ret := got5.OnFlashbangDetonatedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnFlashbangDetonated(c, ret) case "smokegrenade_detonated": - ret := got5.OnSmokeGrenadeDetonatedPayload[TMatchID]{} + ret := got5.OnSmokeGrenadeDetonatedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnSmokeGrenadeDetonated(c, ret) case "decoygrenade_started": - ret := got5.OnDecoyStartedPayload[TMatchID]{} + ret := got5.OnDecoyStartedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnDecoyStarted(c, ret) case "bomb_planted": - ret := got5.OnBombPlantedPayload[TMatchID]{} + ret := got5.OnBombPlantedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnBombPlanted(c, ret) case "bomb_defused": - ret := got5.OnBombDefusedPayload[TMatchID]{} + ret := got5.OnBombDefusedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnBombDefused(c, ret) case "bomb_exploded": - ret := got5.OnBombExplodedPayload[TMatchID]{} + ret := got5.OnBombExplodedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnBombExploded(c, ret) case "player_connect": - ret := got5.OnPlayerConnectedPayload[TMatchID]{} + ret := got5.OnPlayerConnectedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnPlayerConnected(c, ret) case "player_disconnect": - ret := got5.OnPlayerDisconnectedPayload[TMatchID]{} + ret := got5.OnPlayerDisconnectedPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return } ctrl.HandleOnPlayerDisconnected(c, ret) case "player_say": - ret := got5.OnPlayerSayPayload[TMatchID]{} + ret := got5.OnPlayerSayPayload{} if err := reMarshal(p, &ret); err != nil { c.AbortWithError(http.StatusBadRequest, xerrors.New("Invalid JSON")) // TODO: Wrap error code return @@ -289,7 +289,7 @@ func OnEventHandler[TMatchID got5.MatchID](ctrl got5.EventHandler[TMatchID]) fun } // CheckEventHandlerAuth Check Auth -func CheckEventHandlerAuth[TMatchID got5.MatchID](auth got5.Auth[TMatchID]) func(c *gin.Context) { +func CheckEventHandlerAuth(auth got5.Auth) func(c *gin.Context) { return (func(c *gin.Context) { // NOTICE: get5_remote_log_header_value only supports max 128 characters reqAuth := c.GetHeader("Authorization") diff --git a/route/gin/match.go b/route/gin/match.go index 5339e70..fe4e846 100644 --- a/route/gin/match.go +++ b/route/gin/match.go @@ -9,7 +9,7 @@ import ( ) // CheckMatchLoaderAuth 認証用ハンドラ -func CheckMatchLoaderAuth[TMatchID got5.MatchID](auth got5.Auth[TMatchID]) func(c *gin.Context) { +func CheckMatchLoaderAuth(auth got5.Auth) func(c *gin.Context) { return (func(c *gin.Context) { matchID := c.Param("matchID") reqAuthVal := c.GetHeader("Authorization") @@ -19,7 +19,7 @@ func CheckMatchLoaderAuth[TMatchID got5.MatchID](auth got5.Auth[TMatchID]) func( c.AbortWithError(http.StatusBadRequest, err) return } - if err := auth.MatchAuth(c, TMatchID(mid), reqAuthVal); err != nil { + if err := auth.MatchAuth(c, mid, reqAuthVal); err != nil { c.AbortWithError(http.StatusUnauthorized, err) // カスタムエラーを返したい return } @@ -28,7 +28,7 @@ func CheckMatchLoaderAuth[TMatchID got5.MatchID](auth got5.Auth[TMatchID]) func( } // LoadMatchHandler GET on get5_loadmatch_url "https://example.com/match_config.json" "Authorization" "Bearer " -func LoadMatchHandler[TMatchID got5.MatchID](loader got5.MatchLoader[TMatchID]) func(c *gin.Context) { +func LoadMatchHandler(loader got5.MatchLoader) func(c *gin.Context) { return (func(c *gin.Context) { // マッチを取得、JSONを組んで返す matchID := c.Param("matchID") @@ -38,12 +38,12 @@ func LoadMatchHandler[TMatchID got5.MatchID](loader got5.MatchLoader[TMatchID]) return } - m, err := loader.Load(c, TMatchID(mid)) + m, err := loader.Load(c, mid) if err != nil { // TODO:エラーハンドリングをする c.AbortWithError(http.StatusNotFound, err) return } - c.JSON(http.StatusOK, m.ToG5Format()) + c.JSON(http.StatusOK, m) }) } diff --git a/route/gin/route.go b/route/gin/route.go index 9cf910d..cab9992 100644 --- a/route/gin/route.go +++ b/route/gin/route.go @@ -6,23 +6,23 @@ import ( ) // SetupAllGet5Handlers Setup All Get5-related handlers -func SetupAllGet5Handlers[TMatchID int](evh got5.EventHandler[TMatchID], loader got5.MatchLoader[TMatchID], uploader got5.DemoUploader[TMatchID], auth got5.Auth[TMatchID], r gin.IRoutes) { +func SetupAllGet5Handlers(evh got5.EventHandler, loader got5.MatchLoader, uploader got5.DemoUploader, auth got5.Auth, r gin.IRoutes) { SetupEventHandlers(evh, auth, r) SetupMatchLoadHandler(loader, auth, r) SetupDemoUploadHandler(uploader, auth, r) } // SetupDemoUploadHandler Setup get5 upload demo handler -func SetupDemoUploadHandler[TMatchID int](uploader got5.DemoUploader[TMatchID], auth got5.Auth[TMatchID], r gin.IRoutes) { +func SetupDemoUploadHandler(uploader got5.DemoUploader, auth got5.Auth, r gin.IRoutes) { r.POST("/demo", CheckDemoAuth(auth), DemoUploadHandler(uploader)) } // SetupMatchLoadHandler Setup get5 loadmatch handler -func SetupMatchLoadHandler[TMatchID int](loader got5.MatchLoader[TMatchID], auth got5.Auth[TMatchID], r gin.IRoutes) { +func SetupMatchLoadHandler(loader got5.MatchLoader, auth got5.Auth, r gin.IRoutes) { r.GET("/match/:matchID", CheckMatchLoaderAuth(auth), LoadMatchHandler(loader)) } // SetupEventHandlers get5 handlers to specified fiber.Router -func SetupEventHandlers[TMatchID got5.MatchID](ctrl got5.EventHandler[TMatchID], auth got5.Auth[TMatchID], r gin.IRoutes) { +func SetupEventHandlers(ctrl got5.EventHandler, auth got5.Auth, r gin.IRoutes) { r.POST("/event", CheckEventHandlerAuth(auth), OnEventHandler(ctrl)) }