migration to chi
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user