Skip to content

Commit eb31231

Browse files
committed
feat: update API routes to use "/v1" prefix; change default BasePath to "/relay"; enhance event and endpoint models with default metadata and headers
1 parent d8d5c7e commit eb31231

6 files changed

Lines changed: 55 additions & 43 deletions

File tree

api/forge.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (a *ForgeAPI) RegisterRoutes(router forge.Router) {
6161
// ---------------------------------------------------------------------------
6262

6363
func (a *ForgeAPI) registerEventTypeRoutes(router forge.Router) {
64-
g := router.Group("", forge.WithGroupTags("event-types"))
64+
g := router.Group("/v1", forge.WithGroupTags("event-types"))
6565

6666
if err := g.POST("/event-types", a.createEventType,
6767
forge.WithSummary("Register event type"),
@@ -201,7 +201,7 @@ func (a *ForgeAPI) deleteEventType(ctx forge.Context, req *DeleteEventTypeForgeR
201201
// ---------------------------------------------------------------------------
202202

203203
func (a *ForgeAPI) registerEndpointRoutes(router forge.Router) {
204-
g := router.Group("", forge.WithGroupTags("endpoints"))
204+
g := router.Group("/v1", forge.WithGroupTags("endpoints"))
205205

206206
if err := g.POST("/endpoints", a.createEndpoint,
207207
forge.WithSummary("Create endpoint"),
@@ -456,7 +456,7 @@ func (a *ForgeAPI) rotateSecret(ctx forge.Context, req *EndpointActionForgeReque
456456
// ---------------------------------------------------------------------------
457457

458458
func (a *ForgeAPI) registerEventRoutes(router forge.Router) {
459-
g := router.Group("", forge.WithGroupTags("events"))
459+
g := router.Group("/v1", forge.WithGroupTags("events"))
460460

461461
if err := g.POST("/events", a.sendEvent,
462462
forge.WithSummary("Send event"),
@@ -564,7 +564,7 @@ func (a *ForgeAPI) getEvent(ctx forge.Context, req *GetEventForgeRequest) (*even
564564
// ---------------------------------------------------------------------------
565565

566566
func (a *ForgeAPI) registerDeliveryRoutes(router forge.Router) {
567-
g := router.Group("", forge.WithGroupTags("deliveries"))
567+
g := router.Group("/v1", forge.WithGroupTags("deliveries"))
568568

569569
if err := g.GET("/endpoints/:endpointId/deliveries", a.listDeliveries,
570570
forge.WithSummary("List deliveries"),
@@ -617,7 +617,7 @@ func (a *ForgeAPI) listDeliveries(ctx forge.Context, req *ListDeliveriesForgeReq
617617
// ---------------------------------------------------------------------------
618618

619619
func (a *ForgeAPI) registerDLQRoutes(router forge.Router) {
620-
g := router.Group("", forge.WithGroupTags("dlq"))
620+
g := router.Group("/v1", forge.WithGroupTags("dlq"))
621621

622622
if err := g.GET("/dlq", a.listDLQ,
623623
forge.WithSummary("List DLQ entries"),
@@ -720,7 +720,7 @@ func (a *ForgeAPI) replayBulkDLQ(ctx forge.Context, req *ReplayBulkDLQForgeReque
720720
// ---------------------------------------------------------------------------
721721

722722
func (a *ForgeAPI) registerStatsRoutes(router forge.Router) {
723-
g := router.Group("", forge.WithGroupTags("stats"))
723+
g := router.Group("/v1", forge.WithGroupTags("stats"))
724724

725725
if err := g.GET("/stats", a.getStats,
726726
forge.WithSummary("System statistics"),

extension/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type Config struct {
1313
// Config embeds the core relay configuration.
1414
relay.Config `json:",inline" yaml:",inline" mapstructure:",squash"`
1515

16-
// BasePath is the URL prefix for all relay webhook routes (default: "/webhooks").
16+
// BasePath is the URL prefix for all relay webhook routes (default: "/relay").
1717
BasePath string `json:"base_path" yaml:"base_path" mapstructure:"base_path"`
1818

1919
// DisableRoutes disables automatic route registration with the Forge router.
@@ -43,7 +43,7 @@ type Config struct {
4343
func DefaultConfig() Config {
4444
return Config{
4545
Config: relay.DefaultConfig(),
46-
BasePath: "/webhooks",
46+
BasePath: "/relay",
4747
}
4848
}
4949

extension/extension.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (e *Extension) Init(fapp forge.App) error {
160160
if !e.config.DisableRoutes {
161161
basePath := e.config.BasePath
162162
if basePath == "" {
163-
basePath = "/webhooks"
163+
basePath = "/relay"
164164
}
165165
e.api.RegisterRoutes(fapp.Router().Group(basePath))
166166
}
@@ -211,7 +211,7 @@ func (e *Extension) RegisterRoutes(router forge.Router) {
211211
// BasePath returns the configured URL base path.
212212
func (e *Extension) BasePath() string {
213213
if e.config.BasePath == "" {
214-
return "/webhooks"
214+
return "/relay"
215215
}
216216
return e.config.BasePath
217217
}

go.mod

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ require (
66
github.com/a-h/templ v0.3.1001
77
github.com/redis/go-redis/v9 v9.18.0
88
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
9-
github.com/xraph/forge v1.3.1
10-
github.com/xraph/forgeui v1.3.0
11-
github.com/xraph/go-utils v1.0.0
12-
github.com/xraph/grove v1.3.1
13-
github.com/xraph/grove/drivers/mongodriver v1.3.1
14-
github.com/xraph/grove/drivers/pgdriver v1.3.1
15-
github.com/xraph/grove/drivers/sqlitedriver v1.3.1
16-
github.com/xraph/grove/kv v1.3.1
17-
github.com/xraph/grove/kv/drivers/redisdriver v1.3.1
9+
github.com/xraph/forge v1.4.0
10+
github.com/xraph/forgeui v1.4.0
11+
github.com/xraph/go-utils v1.1.0
12+
github.com/xraph/grove v1.4.0
13+
github.com/xraph/grove/drivers/mongodriver v1.4.0
14+
github.com/xraph/grove/drivers/pgdriver v1.4.0
15+
github.com/xraph/grove/drivers/sqlitedriver v1.4.0
16+
github.com/xraph/grove/kv v1.4.0
17+
github.com/xraph/grove/kv/drivers/redisdriver v1.4.0
1818
github.com/xraph/vessel v1.0.0
1919
go.jetify.com/typeid/v2 v2.0.0-alpha.3
2020
go.mongodb.org/mongo-driver/v2 v2.5.0
@@ -116,7 +116,7 @@ require (
116116
golang.org/x/sync v0.19.0 // indirect
117117
golang.org/x/sys v0.41.0 // indirect
118118
golang.org/x/term v0.39.0 // indirect
119-
golang.org/x/text v0.33.0 // indirect
119+
golang.org/x/text v0.34.0 // indirect
120120
golang.org/x/time v0.12.0 // indirect
121121
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
122122
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect

go.sum

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -324,24 +324,24 @@ github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6
324324
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
325325
github.com/xraph/confy v0.1.0 h1:dAdI/ShnkU5PEXVsfR86swoWj6XjJ37BdPQpBIUmg9M=
326326
github.com/xraph/confy v0.1.0/go.mod h1:/uhVfKibPR+kn7MI9LkVVekk84NP0sxsKZ9sFQoQ5Kc=
327-
github.com/xraph/forge v1.3.1 h1:DX8uqNAFNeY+/L/o/PosJIHYSE0pcGzfScxB1Xgl0mM=
328-
github.com/xraph/forge v1.3.1/go.mod h1:SL+lSzFEd9sDw+LTVUeMsVLlWhZM83LMunP2yf6Dm28=
329-
github.com/xraph/forgeui v1.3.0 h1:HPS6+7fndy0qMkD1tB1QNydTOAqQ7oXOTi30+TlXOok=
330-
github.com/xraph/forgeui v1.3.0/go.mod h1:2oXAltVMFHJJG0OmXNzcA/BAEE+8L36LGTlkkDgaPpA=
331-
github.com/xraph/go-utils v1.0.0 h1:P1jOvtDlC5xZyGtnIhypFfPUBgpfyrwESY4TK4P2I5g=
332-
github.com/xraph/go-utils v1.0.0/go.mod h1:yp+PD9dXSA7tA9Pxmuveg5E7Ht1iHIVov8yMvanMG7U=
333-
github.com/xraph/grove v1.3.1 h1:IqM+Ynr4pNwPTUXDxhw7O3n0hkT4YEq/096om5V7pN8=
334-
github.com/xraph/grove v1.3.1/go.mod h1:9G6mvF6KO+AvlaaXQoBevlxiWs/n2p/EhBVNgdYR0FA=
335-
github.com/xraph/grove/drivers/mongodriver v1.3.1 h1:vIAU+oJeAPXqY71w1qN35ts0xMiBUyqbsinbu5u9KfQ=
336-
github.com/xraph/grove/drivers/mongodriver v1.3.1/go.mod h1:P+msnEenoXJnNWFh/wWi/EzAqjsdscq3EthcCqSDwaY=
337-
github.com/xraph/grove/drivers/pgdriver v1.3.1 h1:Mw60dFmOVhenclJjRTlt32Q4coayPLoU52NNS9gnHgM=
338-
github.com/xraph/grove/drivers/pgdriver v1.3.1/go.mod h1:ogSHbP1rbZO/5UnfYWhBzrRlEtwH4V4T0hrl/8GlTzU=
339-
github.com/xraph/grove/drivers/sqlitedriver v1.3.1 h1:4G5XWm/M2VqMB0WtHlXSXT1lH+YoXJ+RuvwB94gwxvU=
340-
github.com/xraph/grove/drivers/sqlitedriver v1.3.1/go.mod h1:AIyBtYUgMrtzrvtB6sHU/EyEEeRf/TPrgDGDV7uKpOQ=
341-
github.com/xraph/grove/kv v1.3.1 h1:c4t35bgBL6GxLRUk+3ZOAt+L3xA6wXezd2V0JQVf/Hg=
342-
github.com/xraph/grove/kv v1.3.1/go.mod h1:+MLJ+ZcHUtKjGCoXfykzsG/Gthyry8hrD4Eg0aNskOs=
343-
github.com/xraph/grove/kv/drivers/redisdriver v1.3.1 h1:ir/2cyWqR4gs1TylrIWJnjqQ7DuW5BKtyyIfBbU+rv4=
344-
github.com/xraph/grove/kv/drivers/redisdriver v1.3.1/go.mod h1:6dXl6MHpelml7bIznfkxdir+BX/fySt6ooByrq20944=
327+
github.com/xraph/forge v1.4.0 h1:+7NjO2iz9+JGxwDFS3hfNp73/JiqHlXYxWN5nD3WqbM=
328+
github.com/xraph/forge v1.4.0/go.mod h1:M+aj9K6XOBkYvVWnwESqCuFcn8/P6lu0C1tknBqz3Mg=
329+
github.com/xraph/forgeui v1.4.0 h1:RhpRbecimGCSDf0XQnJhl5PmQjbxrF5M2PGEk6F60sg=
330+
github.com/xraph/forgeui v1.4.0/go.mod h1:rH/+wb1tt2pXSHotWAvoP+Lt846xlIjuwPDSpS5K5mw=
331+
github.com/xraph/go-utils v1.1.0 h1:bPO4C/mwm0I5ZZa3RxbwUqKhy3Vnxvm3s98vmX8CrjY=
332+
github.com/xraph/go-utils v1.1.0/go.mod h1:tZN4SuGy9otCo6dETp7Cvkgyiy0BvaJaZbTBv4Euvo4=
333+
github.com/xraph/grove v1.4.0 h1:7rv/Ixhp7swZOReax3g/kEVv13p02YkulFmGjv2HLOg=
334+
github.com/xraph/grove v1.4.0/go.mod h1:3vrjpafTi3VA3OD05xIHMRsfqlcZW34+/tOJqzlUvv8=
335+
github.com/xraph/grove/drivers/mongodriver v1.4.0 h1:tfLQBBUoN3l7K4pr6EmwepgSYRB+zVmP9XGjwn+h22U=
336+
github.com/xraph/grove/drivers/mongodriver v1.4.0/go.mod h1:46El0w2/vGeqTTWYTfq9I0sXXxaLBiOJFaXPEEBVwAY=
337+
github.com/xraph/grove/drivers/pgdriver v1.4.0 h1:Ua3XSdVieVT9Ia2WY0kkpTd+QTqhl8GFb8uV6JhZkqE=
338+
github.com/xraph/grove/drivers/pgdriver v1.4.0/go.mod h1:aXris8DoBvJwGTpnF2kMC50aBwpxv/e+4mGMRFpC9B0=
339+
github.com/xraph/grove/drivers/sqlitedriver v1.4.0 h1:kDK5nufN1+pRy7fSk+7VcCxgLjl5azCG8Tgd7c+vGYs=
340+
github.com/xraph/grove/drivers/sqlitedriver v1.4.0/go.mod h1:YwhMU+qclOkK0pRrbfvyuhGRU8eREY5jEfViI2FjqFk=
341+
github.com/xraph/grove/kv v1.4.0 h1:c6/RSFnlK9iff2fFFNSzCgJoUXPMAJRclb9kAMwi1cw=
342+
github.com/xraph/grove/kv v1.4.0/go.mod h1:vMM7s8Vl90WwZACttXWqIHRdggATveaVSAcnoqbiwzY=
343+
github.com/xraph/grove/kv/drivers/redisdriver v1.4.0 h1:THNJami8IBHzVi5H1uPyJWwizj02iyAAHj5IUxyKheE=
344+
github.com/xraph/grove/kv/drivers/redisdriver v1.4.0/go.mod h1:/TMnYUGubFMMxkRJm/JtgmfMtzLArMyPLlKAxkyfdeo=
345345
github.com/xraph/vessel v1.0.0 h1:n2q30d0OGPENpFfmOUgEuS99Y+X6b6WTfzdOHiE4Ds0=
346346
github.com/xraph/vessel v1.0.0/go.mod h1:quT3UWDXZF0RLL34H3ijXP9kVnh2pdfnn0f2s3ezChA=
347347
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
@@ -453,8 +453,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
453453
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
454454
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
455455
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
456-
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
457-
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
456+
golang.org/x/text v0.34.0 h1:oL/Qq0Kdaqxa1KbNeMKwQq0reLCCaFtqu2eNuSeNHbk=
457+
golang.org/x/text v0.34.0/go.mod h1:homfLqTYRFyVYemLBFl5GgL/DWEiH5wcsQ5gSh1yziA=
458458
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
459459
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
460460
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

store/postgres/models.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ type eventTypeModel struct {
3838
}
3939

4040
func toEventTypeModel(et *catalog.EventType) *eventTypeModel {
41+
md := et.Metadata
42+
if md == nil {
43+
md = map[string]string{}
44+
}
4145
return &eventTypeModel{
4246
ID: et.ID.String(),
4347
Name: et.Definition.Name,
@@ -50,7 +54,7 @@ func toEventTypeModel(et *catalog.EventType) *eventTypeModel {
5054
IsDeprecated: et.IsDeprecated,
5155
DeprecatedAt: et.DeprecatedAt,
5256
ScopeAppID: et.ScopeAppID,
53-
Metadata: et.Metadata,
57+
Metadata: md,
5458
CreatedAt: et.CreatedAt,
5559
UpdatedAt: et.UpdatedAt,
5660
}
@@ -103,17 +107,25 @@ type endpointModel struct {
103107
}
104108

105109
func toEndpointModel(ep *endpoint.Endpoint) *endpointModel {
110+
headers := ep.Headers
111+
if headers == nil {
112+
headers = map[string]string{}
113+
}
114+
md := ep.Metadata
115+
if md == nil {
116+
md = map[string]string{}
117+
}
106118
return &endpointModel{
107119
ID: ep.ID.String(),
108120
TenantID: ep.TenantID,
109121
URL: ep.URL,
110122
Description: ep.Description,
111123
Secret: ep.Secret,
112124
EventTypes: ep.EventTypes,
113-
Headers: ep.Headers,
125+
Headers: headers,
114126
Enabled: ep.Enabled,
115127
RateLimit: ep.RateLimit,
116-
Metadata: ep.Metadata,
128+
Metadata: md,
117129
CreatedAt: ep.CreatedAt,
118130
UpdatedAt: ep.UpdatedAt,
119131
}

0 commit comments

Comments
 (0)