2025-02-22 16:15:38 +08:00
|
|
|
package internalhttp
|
|
|
|
|
|
|
|
|
|
import (
|
2025-02-27 07:25:25 +08:00
|
|
|
authhttp "legalgo-BE-go/internal/api/http/auth"
|
2025-03-01 21:20:51 +08:00
|
|
|
categoryhttp "legalgo-BE-go/internal/api/http/category"
|
2025-03-02 04:36:17 +08:00
|
|
|
newshttp "legalgo-BE-go/internal/api/http/news"
|
2025-03-03 18:59:25 +07:00
|
|
|
osshttp "legalgo-BE-go/internal/api/http/oss"
|
2025-02-27 07:25:25 +08:00
|
|
|
subscribeplanhttp "legalgo-BE-go/internal/api/http/subscribe_plan"
|
2025-03-01 20:00:54 +08:00
|
|
|
taghttp "legalgo-BE-go/internal/api/http/tag"
|
2025-02-27 07:25:25 +08:00
|
|
|
|
2025-02-22 16:15:38 +08:00
|
|
|
"github.com/go-chi/chi/v5"
|
|
|
|
|
"github.com/go-chi/cors"
|
2025-02-23 22:34:26 +08:00
|
|
|
"github.com/go-playground/validator/v10"
|
2025-02-22 16:15:38 +08:00
|
|
|
"go.uber.org/fx"
|
|
|
|
|
|
|
|
|
|
chimware "github.com/go-chi/chi/v5/middleware"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var Module = fx.Module("router",
|
2025-02-23 22:34:26 +08:00
|
|
|
fx.Provide(
|
|
|
|
|
initRouter,
|
|
|
|
|
validator.New,
|
|
|
|
|
),
|
|
|
|
|
authhttp.Module,
|
2025-02-24 16:48:20 +08:00
|
|
|
subscribeplanhttp.Module,
|
2025-03-01 20:00:54 +08:00
|
|
|
taghttp.Module,
|
2025-03-01 21:20:51 +08:00
|
|
|
categoryhttp.Module,
|
2025-03-02 04:36:17 +08:00
|
|
|
newshttp.Module,
|
2025-03-03 18:59:25 +07:00
|
|
|
osshttp.Module,
|
2025-02-22 16:15:38 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|