Files
api-golang/internal/routes/routes.go
Flavio Fois 576ce0b1b5
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 43s
add v2 API routes for admin and bug report management with rate limiting
2026-03-23 21:29:50 +01:00

28 lines
593 B
Go

package routes
import (
v2 "emly-api-go/internal/routes/v2"
"net/http"
v1 "emly-api-go/internal/routes/v1"
"github.com/go-chi/chi/v5"
"github.com/jmoiron/sqlx"
)
// RegisterAll mounts every versioned API onto the root router.
// To add a new API version, create internal/routes/v2 and add:
//
// r.Mount("/v2", v2.NewRouter(db))
func RegisterAll(r chi.Router, db *sqlx.DB) {
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
_, err := w.Write([]byte("emly-api-go"))
if err != nil {
return
}
})
r.Mount("/v1", v1.NewRouter(db))
r.Mount("/v2", v2.NewRouter(db))
}