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/group/routes.go
2019-05-27 23:46:09 +02:00

23 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
}