23 lines
615 B
Go
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
|
|
}
|