24 lines
621 B
Go
24 lines
621 B
Go
|
package group
|
||
|
|
||
|
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.Group{}), "group")
|
||
|
|
||
|
router.Post("/", features.CreateHandler(&data.Group{}, s))
|
||
|
router.Get("/{id}", queryOneHandler(s, t))
|
||
|
router.Get("/", queryHandler(s, t))
|
||
|
router.Put("/{id}", features.UpdateHandler(&data.Group{}, s))
|
||
|
router.Delete("/{id}", features.DeleteHandler(&data.Group{}, s))
|
||
|
|
||
|
return router
|
||
|
}
|