FILE / Unmei/Backend
v1/games_routes.go
Исходный файл и его история в репозитории.
20 lines
344 B
Go
20 lines
344 B
Go
package v1
|
|
|
|
import (
|
|
"github.com/gorilla/mux"
|
|
"net/http"
|
|
"strconv"
|
|
)
|
|
|
|
func RegisterGamesRoutes(r *mux.Router) {
|
|
r.HandleFunc("/games/{id:[0-9]+}", resolveGame)
|
|
}
|
|
|
|
func resolveGame(w http.ResponseWriter, r *http.Request) {
|
|
vars := mux.Vars(r)
|
|
id, _ := strconv.Atoi(vars["id"])
|
|
game, err := FetchGame(int32(id))
|
|
Response(w, err, game)
|
|
}
|
|
|