moved webhook initialization down

This commit is contained in:
2026-01-11 15:42:03 -07:00
parent 388902a1a0
commit 23f527b769
2 changed files with 40 additions and 41 deletions
+22
View File
@@ -19,6 +19,8 @@ import (
"ruben/inventory2/internal/domains/raw_events"
"ruben/inventory2/internal/server/middleware"
"ruben/inventory2/internal/server/response"
"ruben/inventory2/internal/server/webhooks"
etsy_webhooks "ruben/inventory2/internal/server/webhooks/etsy"
)
type Server struct {
@@ -143,10 +145,12 @@ func NewServer(
// login
// TODO: consider a separate '/login or /auth' router
mux.Handle("GET /login", s.loginPage)
mux.Handle("GET /login/callback", s.loginCallback)
mux.Handle("GET /logout", s.logoutPage)
// TODO: consider a separate '/accounts' router
// /accounts
mux.Handle("POST /accounts", withAuth(s.createAccount))
@@ -156,6 +160,24 @@ func NewServer(
mux.Handle("DELETE /accounts/{acctID}/inventory/sync-groups/draft/listings/{orderIndex}", withAuth(s.deleteSyncGroupListingDraft))
mux.Handle("POST /accounts/{acctID}/inventory/sync-groups", withAuth(s.saveNewSyncGroup))
// TODO: consider a webhook separate router
// webhooks
webhookHandler := http.StripPrefix("/webhooks", webhooks.New(
logger.WithGroup("webhooks"),
rawEvents,
etsy,
webhooks.Config{
Etsy: etsy_webhooks.Config{
OAuthRedirectURIWithAcctIDParam: "/oauth/account/{acctID}/auth_code",
},
},
))
mux.Mux.Handle("GET /webhooks/", webhookHandler)
mux.Mux.Handle("POST /webhooks/", webhookHandler)
mux.Mux.Handle("PUT /webhooks/", webhookHandler)
// TODO: consider a separate webpage router
// webpage content
// non-html content: scripts, styles, images, etc