api

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VERSION get5-web-go Version
	VERSION = "0.1.2"
)

Variables

View Source
var (
	ActiveMapPool  []string
	ReserveMapPool []string
)

Functions

func CheckLoggedIn

func CheckLoggedIn(c *gin.Context)

CheckLoggedIn handler for /api/v1/CheckLoggedIn API.

func CheckUserCanEdit

func CheckUserCanEdit(c *gin.Context)

func CreateMatch

func CreateMatch(c *gin.Context)

CreateMatch Registers match info

func CreateServer

func CreateServer(c *gin.Context)

CreateServer Register server to DB

func CreateTeam

func CreateTeam(c *gin.Context)

CreateTeam Registers team info to DB

func DeleteServer

func DeleteServer(c *gin.Context)

DeleteServer Deletes Server information

func DeleteTeam

func DeleteTeam(c *gin.Context)

DeleteTeam Deletes team

func EditServer

func EditServer(c *gin.Context)

EditServer Edits Server information

func EditTeam

func EditTeam(c *gin.Context)

EditTeam Edits team information

func GetMapList added in v0.1.2

func GetMapList(c *gin.Context)

GetMapList handler for /api/v1/GetMapList API.

func GetMatchInfo

func GetMatchInfo(c *gin.Context)

GetMatchInfo Gets match info by ID

func GetMatches

func GetMatches(c *gin.Context)

func GetMetrics

func GetMetrics(c *gin.Context)

func GetPlayerStatInfo

func GetPlayerStatInfo(c *gin.Context)

func GetRecentMatches

func GetRecentMatches(c *gin.Context)

func GetServerInfo

func GetServerInfo(c *gin.Context)

func GetServerList

func GetServerList(c *gin.Context)

GetServerList Returns registered public server and owned list in JSON

func GetStatusString

func GetStatusString(c *gin.Context)

func GetSteamName

func GetSteamName(c *gin.Context)

GetSteamName Get Steam Profile name by SteamWebAPI

func GetTeamInfo

func GetTeamInfo(c *gin.Context)

func GetTeamList

func GetTeamList(c *gin.Context)

GetTeamList Returns registered team list in JSON.

func GetUserInfo

func GetUserInfo(c *gin.Context)

func GetVersion

func GetVersion(c *gin.Context)

GetVersion handler for /api/v1/GetVersion API.

func MatchAPICheck

func MatchAPICheck(m *db.MatchData, r *http.Request) error

MatchAPICheck Checks if API is available or not

func MatchAddUserHandler

func MatchAddUserHandler(c *gin.Context)

MatchAddUserHandler Handler for /api/v1/match/{matchID}/adduser API.

func MatchCancelHandler

func MatchCancelHandler(c *gin.Context)

MatchCancelHandler Handler for /api/v1/match/{matchID}/cancel API.

func MatchConfigHandler

func MatchConfigHandler(c *gin.Context)

MatchConfigHandler Handler for /api/v1/match/{matchID}/config API.

func MatchDemoUploadHandler

func MatchDemoUploadHandler(c *gin.Context)

MatchDemoUploadHandler Handler for /api/v1/match/{matchID}/map/{mapNumber}/demo API. // TODO

func MatchFinishHandler

func MatchFinishHandler(c *gin.Context)

MatchFinishHandler Handler for /api/v1/match/{matchID}/finish API.

func MatchListBackupsHandler

func MatchListBackupsHandler(c *gin.Context)

MatchListBackupsHandler Handler for /api/v1/match/{matchID}/backup API(GET).

func MatchLoadBackupsHandler

func MatchLoadBackupsHandler(c *gin.Context)

MatchLoadBackupsHandler Handler for /api/v1/match/{matchID}/backup API(POST).

func MatchMapFinishHandler

func MatchMapFinishHandler(c *gin.Context)

MatchMapFinishHandler Handler for /api/v1/match/{matchID}/map/{mapNumber}/finish API.

func MatchMapPlayerUpdateHandler

func MatchMapPlayerUpdateHandler(c *gin.Context)

MatchMapPlayerUpdateHandler Handler for /api/v1/match/{matchID}/map/{mapNumber}/player/{steamid64}/update API.

func MatchMapStartHandler

func MatchMapStartHandler(c *gin.Context)

MatchMapStartHandler Handler for /api/v1/match/{matchID}/map/{mapNumber}/start API.

func MatchMapUpdateHandler

func MatchMapUpdateHandler(c *gin.Context)

MatchMapUpdateHandler Handler for /api/v1/match/{matchID}/map/{mapNumber}/update API.

func MatchPauseHandler

func MatchPauseHandler(c *gin.Context)

MatchPauseHandler Handler for /api/v1/match/{matchID}/pause API.

func MatchRconHandler

func MatchRconHandler(c *gin.Context)

MatchRconHandler Handler for /api/v1/match/{matchID}/rcon API.

func MatchUnpauseHandler

func MatchUnpauseHandler(c *gin.Context)

MatchUnpauseHandler Handler for /api/v1/match/{matchID}/unpause API.

func MatchVetoUpdateHandler

func MatchVetoUpdateHandler(c *gin.Context)

MatchVetoUpdateHandler Handler for /api/v1/match/{matchID}/vetoUpdate API. // TODO

Types

type APIGameServerData

type APIGameServerData struct {
	ID           int    `gorm:"primary_key;column:id;AUTO_INCREMENT;NOT NULL" json:"id"`
	UserID       int    `gorm:"column:user_id;DEFAULT NULL" json:"user_id"`
	InUse        bool   `gorm:"column:in_use;DEFAULT NULL" json:"in_use"`
	IPString     string `gorm:"column:ip_string;DEFAULT NULL" json:"ip_string"`
	Port         int    `gorm:"column:port;DEFAULT NULL" json:"port"`
	Display      string `gorm:"column:display_name" json:"display_name"`
	PublicServer bool   `gorm:"column:public_server;DEFAULT NULL" json:"public_server"`
}

GameServerData Struct for game_server table.

func (*APIGameServerData) TableName

func (u *APIGameServerData) TableName() string

TableName declairation for GORM

type APIMapStatsData

type APIMapStatsData struct {
	ID            int          `gorm:"primary_key" gorm:"column:id" json:"id"`
	MatchID       int          `gorm:"column:match_id" gorm:"ForeignKey:match_id" json:"match_id"`
	MapNumber     int          `gorm:"column:map_number" json:"map_number"`
	MapName       string       `gorm:"column:map_name" json:"map_name"`
	StartTime     sql.NullTime `gorm:"column:start_time" json:"-"`
	StartTimeJSON time.Time    `json:"start_time"`
	EndTime       sql.NullTime `gorm:"column:end_time" json:"-"`
	EndTimeJSON   time.Time    `json:"end_time"`
	Winner        int          `gorm:"column:winner" json:"winner"`
	Team1Score    int          `gorm:"column:team1_score" json:"team1_score"`
	Team2Score    int          `gorm:"column:team2_score" json:"team2_score"`
}

APIMapStatsData MapStatsData struct for map_stats table.

func (*APIMapStatsData) TableName

func (u *APIMapStatsData) TableName() string

TableName declairation for GORM

type APIMatchData

type APIMatchData struct {
	ID            int          `gorm:"primary_key;column:id" json:"id"`
	UserID        int          `gorm:"column:user_id" json:"user_id"`
	Team1         APITeamData  `json:"team1"`
	Team2         APITeamData  `json:"team2"`
	Winner        int64        `gorm:"column:winner" json:"winner"`
	Cancelled     bool         `gorm:"column:cancelled" json:"cancelled"`
	StartTime     sql.NullTime `gorm:"column:start_time" json:"-"`
	StartTimeJSON time.Time    `json:"start_time"`
	EndTime       sql.NullTime `gorm:"column:end_time" json:"-"`
	EndTimeJSON   time.Time    `json:"end_time"`
	MaxMaps       int          `gorm:"column:max_maps" json:"max_maps"`
	Title         string       `gorm:"column:title" json:"title"`
	SkipVeto      bool         `gorm:"column:skip_veto" json:"skip_veto"`
	VetoMapPool   []string     `gorm:"column:veto_mappool" json:"veto_mappool"`
	Team1Score    int          `gorm:"column:team1_score" json:"team1_score"`
	Team2Score    int          `gorm:"column:team2_score" json:"team2_score"`
	Team1String   string       `gorm:"column:team1_string" json:"team1_string"`
	Team2String   string       `gorm:"column:team2_string" json:"team2_string"`
	Forfeit       bool         `gorm:"column:forfeit" json:"forfeit"`

	MapStats []APIMapStatsData `json:"map_stats"`
	Server   APIGameServerData `json:"server"`
	User     APIUserData       `json:"user"`

	Pending bool   `json:"pending"`
	Live    bool   `json:"live"`
	Status  string `json:"status"`
}

APIMatchData Struct for match table.

func (*APIMatchData) TableName

func (u *APIMatchData) TableName() string

TableName declairation for GORM

type APIPlayerStatsData

type APIPlayerStatsData struct {
	ID               int    `gorm:"primary_key;column:id" json:"id"`
	MatchID          int    `gorm:"column:match_id" json:"match_id"`
	MapID            int    `gorm:"column:map_id" json:"map_id"`
	TeamID           int    `gorm:"column:team_id" json:"team_id"`
	SteamID          string `gorm:"column:steam_id;unique" json:"steam_id"`
	Name             string `gorm:"column:name" json:"name"`
	Kills            int    `gorm:"column:kills" json:"kills"`
	Deaths           int    `gorm:"column:deaths" json:"deaths"`
	Roundsplayed     int    `gorm:"column:roundsplayed" json:"roundsplayed"`
	Assists          int    `gorm:"column:assists" json:"assists"`
	FlashbangAssists int    `gorm:"column:flashbang_assists" json:"flashbang_assists"`
	Teamkills        int    `gorm:"column:teamkills" json:"teamkills"`
	Suicides         int    `gorm:"column:suicides" json:"suicides"`
	HeadshotKills    int    `gorm:"column:headshot_kills" json:"headshot_kills"`
	Damage           int64  `gorm:"column:damage" json:"damage"`
	BombPlants       int    `gorm:"column:bomb_plants" json:"bomb_plants"`
	BombDefuses      int    `gorm:"column:bomb_defuses" json:"bomb_defuses"`
	V1               int    `gorm:"column:v1" json:"v1"`
	V2               int    `gorm:"column:v2" json:"v2"`
	V3               int    `gorm:"column:v3" json:"v3"`
	V4               int    `gorm:"column:v4" json:"v4"`
	V5               int    `gorm:"column:v5" json:"v5"`
	K1               int    `gorm:"column:k1" json:"k1"`
	K2               int    `gorm:"column:k2" json:"k2"`
	K3               int    `gorm:"column:k3" json:"k3"`
	K4               int    `gorm:"column:k4" json:"k4"`
	K5               int    `gorm:"column:k5" json:"k5"`
	FirstdeathCT     int    `gorm:"column:firstdeath_Ct" json:"firstdeath_Ct"`
	FirstdeathT      int    `gorm:"column:firstdeath_t" json:"firstdeath_t"`
	FirstkillCT      int    `gorm:"column:firstkill_ct" json:"firstkill_ct"`
	FirstkillT       int    `gorm:"column:firstkill_t" json:"firstkill_t"`

	Rating float64 `json:"rating"`
	KDR    float64 `json:"kdr"`
	HSP    float64 `json:"hsp"`
	ADR    float64 `json:"adr"`
	FPR    float64 `json:"fpr"`
}

APIPlayerStatsData Player stats data struct for player_stats table.

func (*APIPlayerStatsData) GetADR

func (p *APIPlayerStatsData) GetADR() float64

GetADR Returns player's ADR(Average Damage per Round).

func (*APIPlayerStatsData) GetFPR

func (p *APIPlayerStatsData) GetFPR() float64

GetFPR Returns player's FPR(Frags Per Round).

func (*APIPlayerStatsData) GetHSP

func (p *APIPlayerStatsData) GetHSP() float64

GetHSP Returns player's HSP(HeadShot Percentage).

func (*APIPlayerStatsData) GetKDR

func (p *APIPlayerStatsData) GetKDR() float64

GetKDR Returns player's KDR(Kill/Deaths Ratio).

func (*APIPlayerStatsData) GetRating

func (p *APIPlayerStatsData) GetRating() float64

GetRating Get player's rating. Average datas are static tho.

func (*APIPlayerStatsData) TableName

func (p *APIPlayerStatsData) TableName() string

TableName declairation for GORM

type APITeamData

type APITeamData struct {
	ID          int      `gorm:"primary_key;column:id" json:"id"`
	UserID      int      `gorm:"column:user_id" json:"user_id"`
	Name        string   `gorm:"column:name" json:"name"`
	Tag         string   `gorm:"column:tag" json:"tag"`
	Flag        string   `gorm:"column:flag" json:"flag"`
	AuthsPickle []byte   `gorm:"column:auths" json:"-"`
	SteamIDs    []string `gorm:"-" json:"steamids"`
	PublicTeam  bool     `gorm:"column:public_team" json:"public_team"`

	User APIUserData `gorm:"ASSOCIATION_FOREIGNKEY:user_id" json:"-"`
}

TeamData Struct for team table.

func (*APITeamData) GetPlayers

func (t *APITeamData) GetPlayers() ([]string, error)

GetPlayers Gets registered player's steamid64.

func (*APITeamData) TableName

func (t *APITeamData) TableName() string

TableName declairation for GORM

type APIUserData

type APIUserData struct {
	ID      int                  `gorm:"primary_key;column:id;AUTO_INCREMENT" json:"id"`
	SteamID string               `gorm:"column:steam_id;unique" json:"steam_id"`
	Name    string               `gorm:"column:name" json:"name"`
	Admin   bool                 `gorm:"column:admin" json:"admin"`
	Servers []*APIGameServerData `gorm:"ForeignKey:UserID" json:"servers"`
	Teams   []*APITeamData       `gorm:"ForeignKey:UserID" json:"teams"`
	Matches []*APIMatchData      `gorm:"ForeignKey:UserID" json:"matches"`
}

UserData Struct for "user" table.

func (*APIUserData) TableName

func (u *APIUserData) TableName() string

TableName declairation for GORM

type BackupListJSON

type BackupListJSON struct {
	Files []string `json:"files"`
}

BackupListJSON Struct type for /api/v1/match/{matchID}/backup

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL