This repository has been archived on 2019-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
scoreboard/features/game/routes.go
2019-05-27 23:46:09 +02:00

23 lines
615 B
Go

package game
import (
"html/template"
"reflect"
"git.cliffbreak.de/haveachin/scoreboard/data"
"git.cliffbreak.de/haveachin/scoreboard/features"
"github.com/go-chi/chi"
)
func Routes(s features.Service, t *template.Template) *chi.Mux {
router := chi.NewRouter()
s.RegisterCollection(reflect.TypeOf(data.Game{}), "game")
router.Post("/", features.CreateHandler(&data.Game{}, s))
router.Get("/{id}", queryOneHandler(s, t))
router.Get("/", queryHandler(s, t))
router.Put("/{id}", features.UpdateHandler(&data.Game{}, s))
router.Delete("/{id}", features.DeleteHandler(&data.Game{}, s))
return router
}