2023-03-15 10:04:48 +01:00
|
|
|
package backend
|
2022-05-02 17:19:37 +02:00
|
|
|
|
|
|
|
import (
|
2023-05-19 04:50:11 +02:00
|
|
|
"net/http"
|
|
|
|
|
2023-08-16 03:12:25 +02:00
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/routes/v1/auth"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/routes/v1/bot"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/routes/v1/member"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/routes/v1/meta"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/routes/v1/mod"
|
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/routes/v1/user"
|
2023-06-03 16:18:47 +02:00
|
|
|
"codeberg.org/pronounscc/pronouns.cc/backend/server"
|
2022-05-02 17:19:37 +02:00
|
|
|
"github.com/go-chi/chi/v5"
|
2023-05-19 04:50:11 +02:00
|
|
|
"github.com/go-chi/render"
|
|
|
|
|
|
|
|
_ "embed"
|
2022-05-02 17:19:37 +02:00
|
|
|
)
|
|
|
|
|
2023-05-19 04:50:11 +02:00
|
|
|
//go:embed openapi.html
|
|
|
|
var openapi string
|
|
|
|
|
2022-05-02 17:19:37 +02:00
|
|
|
// mountRoutes mounts all API routes on the server's router.
|
|
|
|
// they are all mounted under /v1/
|
|
|
|
func mountRoutes(s *server.Server) {
|
2022-05-04 16:27:16 +02:00
|
|
|
// future-proofing for API versions
|
2022-05-02 17:19:37 +02:00
|
|
|
s.Router.Route("/v1", func(r chi.Router) {
|
|
|
|
auth.Mount(s, r)
|
2022-05-04 16:27:16 +02:00
|
|
|
user.Mount(s, r)
|
2022-09-20 13:02:48 +02:00
|
|
|
member.Mount(s, r)
|
2022-06-17 15:49:16 +02:00
|
|
|
bot.Mount(s, r)
|
2023-03-08 14:13:04 +01:00
|
|
|
meta.Mount(s, r)
|
2023-03-19 16:14:09 +01:00
|
|
|
mod.Mount(s, r)
|
2022-05-02 17:19:37 +02:00
|
|
|
})
|
2023-05-19 04:50:11 +02:00
|
|
|
|
|
|
|
// API docs
|
|
|
|
s.Router.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
render.HTML(w, r, openapi)
|
|
|
|
})
|
2022-05-02 17:19:37 +02:00
|
|
|
}
|