Working swagger api docs

This commit is contained in:
2024-12-03 22:06:57 +01:00
parent e413e955c5
commit dc8fc6c225
8 changed files with 4863 additions and 8 deletions

View File

@@ -11,6 +11,10 @@ import (
"github.com/go-chi/cors"
"github.com/go-chi/httprate"
"github.com/unrolled/secure"
httpSwagger "github.com/swaggo/http-swagger"
_ "novamd/docs" // Swagger docs
)
// setupRouter creates and configures the chi router with middleware and routes
@@ -49,6 +53,12 @@ func setupRouter(o Options) *chi.Mux {
Storage: o.Storage,
}
if o.Config.IsDevelopment {
r.Get("/swagger/*", httpSwagger.Handler(
httpSwagger.URL("/swagger/doc.json"), // The URL pointing to API definition
))
}
// API routes
r.Route("/api/v1", func(r chi.Router) {
// Rate limiting for API routes