moved webhook initialization down
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user