switched to gin

This commit is contained in:
2022-04-17 20:42:15 +02:00
parent 39aea94a59
commit 9ae02cf593
3 changed files with 185 additions and 757 deletions

301
main.go
View File

@@ -16,9 +16,10 @@ import (
"git.harting.dev/csgowtf/csgowtfd/ent/migrate"
"git.harting.dev/csgowtf/csgowtfd/ent/player"
"git.harting.dev/csgowtf/csgowtfd/utils"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/go-redis/cache/v8"
"github.com/go-redis/redis/v8"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
_ "github.com/jackc/pgx/v4/stdlib"
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
@@ -225,11 +226,9 @@ func housekeeping() {
}
}
func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
id := mux.Vars(r)["id"]
l := mux.Vars(r)["limit"]
func getPlayerMeta(c *gin.Context) {
id := c.Param("id")
l := c.Param("limit")
var limit int
var err error
@@ -237,7 +236,7 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
limit, err = strconv.Atoi(l)
if err != nil {
log.Infof("[GPM] limit not an int: %v", err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
} else {
@@ -246,14 +245,14 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
if limit > 10 {
log.Infof("[GPM] limit out of bounds: %d", limit)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tPlayer, err := utils.Player(db, id, conf.Steam.APIKey, nil)
if err != nil {
log.Infof("[GPM] Player not found: %+v", err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -263,7 +262,7 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
metaStats, err = utils.GetMetaStats(tPlayer)
if err != nil {
log.Infof("[GPM] Unable to get MetaStats: %v", err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
@@ -275,7 +274,7 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
})
if err != nil {
log.Errorf("[GPM] Failure saving to cache: %v", err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
log.Debugf("[GPM] SideMetaStats for %d saved to cache", tPlayer.ID)
@@ -304,7 +303,7 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
tP, err := utils.Player(db, p.Player.SteamID64, conf.Steam.APIKey, nil)
if err != nil {
log.Warningf("[GPM] Failure getting player: %v", err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
p.Player.Avatar = tP.Avatar
@@ -324,25 +323,20 @@ func getPlayerMeta(w http.ResponseWriter, r *http.Request) {
}
}
err = utils.SendJSON(metaStats, w)
if err != nil {
log.Errorf("[GPM] Unable to marshal JSON: %v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, metaStats)
}
func getPlayer(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
func getPlayer(c *gin.Context) {
id := mux.Vars(r)["id"]
t := mux.Vars(r)["time"]
id := c.Param("id")
t := c.Param("time")
var offsetTime time.Time
if t != "" {
unixOffset, err := strconv.ParseInt(t, 10, 64)
if err != nil {
log.Infof("[GP] offset not an int: %v", err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
@@ -352,7 +346,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
tPlayer, err := utils.Player(db, id, conf.Steam.APIKey, nil)
if err != nil || tPlayer == nil {
log.Infof("[GP] Player %s not found (%+v)", id, err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -382,12 +376,7 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
}
if err != nil || len(tMatches) == 0 {
log.Debugf("[GP] No matches found for player %s", id)
err := utils.SendJSON(response, w)
if err != nil {
log.Errorf("[GP] Unable to marshal JSON: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
c.JSON(http.StatusOK, response)
return
}
@@ -448,36 +437,23 @@ func getPlayer(w http.ResponseWriter, r *http.Request) {
response.Matches = append(response.Matches, mResponse)
}
err = utils.SendJSON(response, w)
if err != nil {
log.Errorf("[GP] Unable to marshal JSON: %v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, response)
}
func deletePlayerTrack(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
err := r.ParseForm()
if err != nil {
log.Infof("[DPT] Unable to parse form data: %v", err)
w.WriteHeader(http.StatusBadRequest)
return
}
id := mux.Vars(r)["id"]
authCode := r.Form.Get("authcode")
func deletePlayerTrack(c *gin.Context) {
id := c.Param("id")
authCode := c.PostForm("authcode")
if id == "" || authCode == "" || !utils.AuthCodeRegEx.MatchString(authCode) {
log.Infof("[PPTM] invalid arguments: %+v, %+v", id, authCode)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tPlayer, err := utils.Player(db, id, conf.Steam.APIKey, nil)
if err != nil {
log.Infof("[PPT] player not found: %+v", err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -486,11 +462,11 @@ func deletePlayerTrack(w http.ResponseWriter, r *http.Request) {
switch e := err.(type) {
case utils.AuthcodeUnauthorizedError:
log.Infof("[DPT] authCode provided for player %s is invalid: %v", id, e)
w.WriteHeader(http.StatusUnauthorized)
c.Status(http.StatusUnauthorized)
return
default:
log.Infof("[DPT] Temporary Steam-API problem: %v", e)
w.WriteHeader(http.StatusServiceUnavailable)
c.Status(http.StatusServiceUnavailable)
return
}
}
@@ -498,37 +474,28 @@ func deletePlayerTrack(w http.ResponseWriter, r *http.Request) {
err = tPlayer.Update().ClearAuthCode().ClearSharecodeUpdated().Exec(context.Background())
if err != nil {
log.Warningf("[PPT] update player failed: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
c.Status(http.StatusOK)
}
func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
err := r.ParseForm()
if err != nil {
log.Infof("[PPT] Unable to parse form data: %v", err)
w.WriteHeader(http.StatusBadRequest)
return
}
id := mux.Vars(r)["id"]
authCode := strings.TrimSpace(r.Form.Get("authcode"))
shareCode := strings.TrimSpace(r.Form.Get("sharecode"))
func postPlayerTrack(c *gin.Context) {
id := c.Param("id")
authCode := strings.TrimSpace(c.PostForm("authcode"))
shareCode := strings.TrimSpace(c.PostForm("sharecode"))
if id == "" || authCode == "" || !utils.AuthCodeRegEx.MatchString(authCode) {
log.Infof("[PPT] invalid arguments: %+v, %+v, %+v", id, authCode, shareCode)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tPlayer, err := utils.Player(db, id, conf.Steam.APIKey, rL)
if err != nil {
log.Infof("[PPT] player not found: %+v", err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -536,7 +503,7 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
err := demoLoader.LoadDemo(&csgo.Demo{ShareCode: shareCode})
if err != nil {
log.Warningf("[PPT] unable to queue match: %v", err)
w.WriteHeader(http.StatusServiceUnavailable)
c.Status(http.StatusServiceUnavailable)
return
}
}
@@ -546,15 +513,15 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
switch e := err.(type) {
case utils.AuthcodeUnauthorizedError:
log.Infof("[PPT] authCode provided for player %s is invalid: %v", id, e)
w.WriteHeader(http.StatusUnauthorized)
c.Status(http.StatusUnauthorized)
return
case utils.SharecodeNoMatchError:
log.Infof("[PPT] shareCode provided for player %s (%s) is invalid: %v", id, shareCode, e)
w.WriteHeader(http.StatusPreconditionFailed)
c.Status(http.StatusPreconditionFailed)
return
default:
log.Infof("[PPT] problem with request: %v", e)
w.WriteHeader(http.StatusServiceUnavailable)
c.Status(http.StatusServiceUnavailable)
return
}
}
@@ -562,7 +529,7 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
err = tPlayer.Update().SetAuthCode(authCode).Exec(context.Background())
if err != nil {
log.Warningf("[PPT] update player failed: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
@@ -570,22 +537,20 @@ func postPlayerTrack(w http.ResponseWriter, r *http.Request) {
err := demoLoader.LoadDemo(&csgo.Demo{ShareCode: shareCode})
if err != nil {
log.Warningf("[PPT] unable to queue match: %v", err)
w.WriteHeader(http.StatusServiceUnavailable)
c.Status(http.StatusServiceUnavailable)
return
}
}
w.WriteHeader(http.StatusAccepted)
c.Status(http.StatusAccepted)
}
func getMatchParse(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
shareCode := mux.Vars(r)["sharecode"]
func getMatchParse(c *gin.Context) {
shareCode := c.Param("sharecode")
if shareCode == "" || !utils.ShareCodeRegEx.MatchString(shareCode) {
log.Infof("[PPTM] invalid arguments: %s", shareCode)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
@@ -594,34 +559,32 @@ func getMatchParse(w http.ResponseWriter, r *http.Request) {
})
if err != nil {
log.Warningf("[PPTM] unable to queue match: %v", err)
w.WriteHeader(http.StatusServiceUnavailable)
c.Status(http.StatusServiceUnavailable)
return
}
w.WriteHeader(http.StatusAccepted)
c.Status(http.StatusAccepted)
}
func getMatchRounds(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
id := mux.Vars(r)["id"]
func getMatchRounds(c *gin.Context) {
id := c.Param("id")
if id == "" {
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
matchId, err := strconv.ParseUint(id, 10, 64)
if err != nil {
log.Infof("[GMR] Error parsing matchID %s: %v", id, err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tStats, err := db.MatchPlayer.Query().Where(matchplayer.HasMatchesWith(match.ID(matchId))).All(context.Background())
if err != nil {
log.Infof("[GMR] match %d not found: %+v", matchId, err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -643,38 +606,32 @@ func getMatchRounds(w http.ResponseWriter, r *http.Request) {
}
}
err = utils.SendJSON(resp, w)
if err != nil {
log.Errorf("[GMR] JSON: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, resp)
}
func getMatchChat(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
id := mux.Vars(r)["id"]
trans := r.FormValue("translate")
func getMatchChat(c *gin.Context) {
id := c.Param("id")
trans := c.PostForm("translate")
if id == "" {
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tag, weights, err := language.ParseAcceptLanguage(r.Header.Get("Accept-Language"))
tag, weights, err := language.ParseAcceptLanguage(c.GetHeader("Accept-Language"))
if err != nil {
log.Warningf("[GMC] Unable to parse Accept-Language %s: %v", r.Header.Get("Accept-Language"), err)
w.WriteHeader(http.StatusBadRequest)
log.Warningf("[GMC] Unable to parse Accept-Language %s: %v", c.GetHeader("Accept-Language"), err)
c.Status(http.StatusBadRequest)
return
}
lang, _ := tag[0].Base()
log.Debugf("[GMC] Got header %s, selected %s from %v (w: %v)", r.Header.Get("Accept-Language"), lang, tag, weights)
log.Debugf("[GMC] Got header %s, selected %s from %v (w: %v)", c.GetHeader("Accept-Language"), lang, tag, weights)
var translate bool
if trans != "" {
translate, err = strconv.ParseBool(trans)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
}
@@ -682,7 +639,7 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
matchId, err := strconv.ParseUint(id, 10, 64)
if err != nil {
log.Infof("[GMC] Error parsing matchID %s: %v", id, err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
@@ -693,7 +650,7 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
tStats, err := db.Messages.Query().Where(messages.HasMatchPlayerWith(matchplayer.HasMatchesWith(match.ID(matchId)))).WithMatchPlayer().All(context.Background())
if err != nil {
log.Infof("[GMC] match %d not found: %+v", matchId, err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -741,7 +698,7 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
})
if err != nil {
log.Errorf("[GMC] Failure saving to cache: %v", err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
}
@@ -749,7 +706,7 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
tStats, err := db.Messages.Query().Where(messages.HasMatchPlayerWith(matchplayer.HasMatchesWith(match.ID(matchId)))).WithMatchPlayer().All(context.Background())
if err != nil {
log.Infof("[GMC] match %d not found: %+v", matchId, err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -767,34 +724,28 @@ func getMatchChat(w http.ResponseWriter, r *http.Request) {
}
}
err = utils.SendJSON(resp, w)
if err != nil {
log.Errorf("[GMC] JSON: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, resp)
}
func getMatchWeapons(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
id := mux.Vars(r)["id"]
func getMatchWeapons(c *gin.Context) {
id := c.Param("id")
if id == "" {
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
matchId, err := strconv.ParseUint(id, 10, 64)
if err != nil {
log.Infof("[GMW] Error parsing matchID %s: %v", id, err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tStats, err := db.MatchPlayer.Query().Where(matchplayer.HasMatchesWith(match.ID(matchId))).All(context.Background())
if err != nil {
log.Infof("[GMW] match %d not found: %+v", matchId, err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -859,24 +810,18 @@ func getMatchWeapons(w http.ResponseWriter, r *http.Request) {
mResponse.Spray = append(mResponse.Spray, rSprays)
}
err = utils.SendJSON(mResponse, w)
if err != nil {
log.Errorf("[GMW] JSON: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, mResponse)
}
func getMatches(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
t := mux.Vars(r)["time"]
func getMatches(c *gin.Context) {
t := c.Param("time")
var offsetTime time.Time
if t != "" {
unixOffset, err := strconv.ParseInt(t, 10, 64)
if err != nil {
log.Infof("[GMS] offset not an int: %v", err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
@@ -894,12 +839,7 @@ func getMatches(w http.ResponseWriter, r *http.Request) {
}
if err != nil || len(tMatches) == 0 {
log.Debug("[GMS] No matches found")
err := utils.SendJSON(mResponse, w)
if err != nil {
log.Errorf("[GMS] Unable to marshal JSON: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
c.JSON(http.StatusOK, mResponse)
return
}
@@ -934,34 +874,28 @@ func getMatches(w http.ResponseWriter, r *http.Request) {
})
}
err = utils.SendJSON(mResponse, w)
if err != nil {
log.Errorf("[GM] JSON: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, mResponse)
}
func getMatch(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
id := mux.Vars(r)["id"]
func getMatch(c *gin.Context) {
id := c.Param("id")
if id == "" {
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
matchId, err := strconv.ParseUint(id, 10, 64)
if err != nil {
log.Infof("[GM] Unable to parse matchID %s: %v", id, err)
w.WriteHeader(http.StatusBadRequest)
c.Status(http.StatusBadRequest)
return
}
tMatch, err := db.Match.Query().Where(match.ID(matchId)).Only(context.Background())
if err != nil {
log.Infof("[GM] match %d not found: %v", matchId, err)
w.WriteHeader(http.StatusNotFound)
c.Status(http.StatusNotFound)
return
}
@@ -1001,7 +935,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
tStats, err := tMatch.QueryStats().WithPlayers().All(context.Background())
if err != nil {
log.Errorf("[GM] Unable to find stats for match %d: %v", tMatch.ID, err)
w.WriteHeader(http.StatusInternalServerError)
c.Status(http.StatusInternalServerError)
return
}
@@ -1063,11 +997,7 @@ func getMatch(w http.ResponseWriter, r *http.Request) {
}
mResponse.Stats = tmpStats
err = utils.SendJSON(mResponse, w)
if err != nil {
log.Errorf("[GM] JSON: %+v", err)
w.WriteHeader(http.StatusInternalServerError)
}
c.JSON(http.StatusOK, mResponse)
}
/*
@@ -1174,50 +1104,25 @@ func main() {
// start housekeeper
go housekeeping()
// routes
router = mux.NewRouter().StrictSlash(true)
router.HandleFunc("/player/{id}", func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc("/player/{id}", getPlayer).Methods(http.MethodGet)
r := gin.Default()
config := cors.DefaultConfig()
config.AllowOrigins = conf.Httpd.CORSAllowDomains
router.HandleFunc(`/player/{id}/next/{time:\d+}`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/player/{id}/next/{time:\d+}`, getPlayer).Methods(http.MethodGet)
r.Use(cors.New(config))
router.HandleFunc(`/player/{id}/meta/{limit:\d+}`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/player/{id}/meta/{limit:\d+}`, getPlayerMeta).Methods(http.MethodGet)
router.HandleFunc("/player/{id}/meta", func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc("/player/{id}/meta", getPlayerMeta).Methods(http.MethodGet)
router.HandleFunc("/player/{id}/track", func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc("/player/{id}/track", postPlayerTrack).Methods(http.MethodPost)
router.HandleFunc("/player/{id}/track", deletePlayerTrack).Methods(http.MethodDelete)
router.HandleFunc("/match/parse/{sharecode}", func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc("/match/parse/{sharecode}", getMatchParse).Methods(http.MethodGet)
router.HandleFunc(`/match/{id:\d{19}}`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/match/{id:\d{19}}`, getMatch).Methods(http.MethodGet)
router.HandleFunc(`/match/{id:\d{19}}/weapons`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/match/{id:\d{19}}/weapons`, getMatchWeapons).Methods(http.MethodGet)
router.HandleFunc(`/match/{id:\d{19}}/rounds`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/match/{id:\d{19}}/rounds`, getMatchRounds).Methods(http.MethodGet)
router.HandleFunc(`/match/{id:\d{19}}/chat`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/match/{id:\d{19}}/chat`, getMatchChat).Methods(http.MethodGet)
router.HandleFunc(`/match/{id:\d{19}}/chat`, getMatchChat).Queries("translate", "{translate}").Methods(http.MethodGet)
router.HandleFunc(`/matches`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/matches`, getMatches).Methods(http.MethodGet)
router.HandleFunc(`/matches/next/{time:\d+}`, func(writer http.ResponseWriter, request *http.Request) {}).Methods(http.MethodOptions)
router.HandleFunc(`/matches/next/{time:\d+}`, getMatches).Methods(http.MethodGet)
router.Use(mux.CORSMethodMiddleware(router))
loggedRouter := handlers.LoggingHandler(os.Stdout, router)
proxyRouter := handlers.ProxyHeaders(loggedRouter)
cors := handlers.CORS(handlers.AllowedOrigins(conf.Httpd.CORSAllowDomains))
r.GET("/player/:id", getPlayer)
r.GET("/player/:id/next/:time", getPlayer)
r.GET("/player/:id/meta/:limit", getPlayerMeta)
r.GET("/player/:id/meta", getPlayerMeta)
r.POST("/player/:id/track", postPlayerTrack)
r.DELETE("/player/:id/track", deletePlayerTrack)
r.GET("/match/parse/:sharecode", getMatchParse)
r.GET("/match/:id", getMatch)
r.GET("/match/:id/weapons", getMatchWeapons)
r.GET("/match/:id/rounds", getMatchRounds)
r.GET("/match/:id/chat", getMatchChat)
r.GET("/matches", getMatches)
r.GET("/matches/next/:time")
log.Info("Start listening...")
@@ -1236,7 +1141,7 @@ func main() {
ReadTimeout: time.Duration(conf.Csgowtfd.Timeout.Read) * time.Second,
WriteTimeout: time.Duration(conf.Csgowtfd.Timeout.Write) * time.Second,
IdleTimeout: time.Duration(conf.Csgowtfd.Timeout.Idle) * time.Second,
Handler: cors(proxyRouter),
Handler: r,
}
_ = srv.Serve(sL)
}()
@@ -1251,7 +1156,7 @@ func main() {
ReadTimeout: time.Duration(conf.Csgowtfd.Timeout.Read) * time.Second,
WriteTimeout: time.Duration(conf.Csgowtfd.Timeout.Write) * time.Second,
IdleTimeout: time.Duration(conf.Csgowtfd.Timeout.Idle) * time.Second,
Handler: cors(proxyRouter),
Handler: r,
}
err = srv.Serve(tL)
if err != nil {