diff --git a/internal/rest/controllers/routes.go b/internal/rest/controllers/routes.go index 5278612..6553db8 100644 --- a/internal/rest/controllers/routes.go +++ b/internal/rest/controllers/routes.go @@ -8,12 +8,12 @@ import ( "github.com/opsway-io/backend/internal/check" "github.com/opsway-io/backend/internal/monitor" "github.com/opsway-io/backend/internal/rest/controllers/authentication" - "github.com/opsway-io/backend/internal/rest/controllers/billings" "github.com/opsway-io/backend/internal/rest/controllers/changelogs" "github.com/opsway-io/backend/internal/rest/controllers/healthz" "github.com/opsway-io/backend/internal/rest/controllers/monitors" "github.com/opsway-io/backend/internal/rest/controllers/teams" "github.com/opsway-io/backend/internal/rest/controllers/users" + "github.com/opsway-io/backend/internal/rest/controllers/webhooks" "github.com/opsway-io/backend/internal/rest/helpers" "github.com/opsway-io/backend/internal/rest/middleware" "github.com/opsway-io/backend/internal/team" @@ -36,7 +36,6 @@ func Register( changelogService changelog.Service, ) { AuthGuard := middleware.AuthGuardFactory(logger, authenticationService) - StripeGuard := middleware.StripeGuardFactory(logger) root := e.Group( "/v1", @@ -47,14 +46,9 @@ func Register( AuthGuard(), ) - stripeRoot := e.Group( - "/stripe", - StripeGuard(), - ) - - // Stripe + // Webhooks - billings.Register(stripeRoot, logger, billingService) + webhooks.Register(root, logger, billingService) // Healthz diff --git a/internal/rest/controllers/billings/routes.go b/internal/rest/controllers/webhooks/routes.go similarity index 69% rename from internal/rest/controllers/billings/routes.go rename to internal/rest/controllers/webhooks/routes.go index f68efaf..79d7b66 100644 --- a/internal/rest/controllers/billings/routes.go +++ b/internal/rest/controllers/webhooks/routes.go @@ -1,10 +1,11 @@ -package billings +package webhooks import ( "github.com/labstack/echo/v4" "github.com/opsway-io/backend/internal/authentication" "github.com/opsway-io/backend/internal/billing" "github.com/opsway-io/backend/internal/rest/handlers" + "github.com/opsway-io/backend/internal/rest/middleware" "github.com/sirupsen/logrus" ) @@ -22,8 +23,14 @@ func Register( BillingService: billingService, } - StripeHandler := handlers.StripeHandlerFactory(logger) + root := e.Group( + "/webhooks", + ) + + // Stripe - e.POST("/webhook", StripeHandler(h.handleWebhook)) + StripeGuard := middleware.StripeGuardFactory(logger) + StripeHandler := handlers.StripeHandlerFactory(logger) + root.POST("/stripe", StripeHandler(h.handleWebhook), StripeGuard()) } diff --git a/internal/rest/controllers/billings/billing.go b/internal/rest/controllers/webhooks/stripe.go similarity index 98% rename from internal/rest/controllers/billings/billing.go rename to internal/rest/controllers/webhooks/stripe.go index b4311da..0333748 100644 --- a/internal/rest/controllers/billings/billing.go +++ b/internal/rest/controllers/webhooks/stripe.go @@ -1,4 +1,4 @@ -package billings +package webhooks import ( "io" diff --git a/main b/main new file mode 100755 index 0000000..b239209 Binary files /dev/null and b/main differ diff --git a/main.go b/main.go deleted file mode 100644 index 3f8595e..0000000 --- a/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/opsway-io/backend/cmd" - -func main() { - cmd.Execute() -}