2025-03-01 21:20:51 +08:00

45 lines
1.0 KiB
Go

package internalhttp
import (
authhttp "legalgo-BE-go/internal/api/http/auth"
categoryhttp "legalgo-BE-go/internal/api/http/category"
subscribeplanhttp "legalgo-BE-go/internal/api/http/subscribe_plan"
taghttp "legalgo-BE-go/internal/api/http/tag"
"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
"github.com/go-playground/validator/v10"
"go.uber.org/fx"
chimware "github.com/go-chi/chi/v5/middleware"
)
var Module = fx.Module("router",
fx.Provide(
initRouter,
validator.New,
),
authhttp.Module,
subscribeplanhttp.Module,
taghttp.Module,
categoryhttp.Module,
)
func initRouter() chi.Router {
router := chi.NewRouter()
localCors := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"},
AllowedHeaders: []string{"Accept", "Content-Type", "Authorization", "X-Device", "X-Client-Ip"},
AllowCredentials: true,
Debug: true,
})
router.Use(
localCors.Handler,
chimware.RequestID,
)
return router
}