FILE / Unmei/Backend

routes/groups.go

Исходный файл и его история в репозитории.
FILE 45bb32e7a6664f9c680c83ff29b4ed1b934d7912
Files
Backend/routes/groups.go
T
2025-03-12 16:30:40 +03:00

28 lines
551 B
Go

package routes
import (
"backend/database"
"github.com/go-chi/chi/v5"
"net/http"
)
func RegisterGroupsRoutes(r chi.Router) {
r.Route("/groups", func(s chi.Router) {
s.Get("/", getGroups)
})
r.Route("/groups/{id:[0-9]+}", func(s chi.Router) {
s.Get("/", getGroup)
})
}
func getGroups(w http.ResponseWriter, r *http.Request) {
groups, err := database.GetGroups()
Response(w, err, groups)
}
func getGroup(w http.ResponseWriter, r *http.Request) {
id := IURLParam(r, "id")
group, err := database.GetGroup(id)
Response(w, err, group)
}