Skip to content

Commit 712ea98

Browse files
committed
feat: update base path from /api/cp to /ctrlplane across the application
1 parent 6fc6bd7 commit 712ea98

11 files changed

Lines changed: 47 additions & 43 deletions

File tree

cmd/controlplane/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func run() error {
4343
cpExt := extension.New(
4444
extension.WithStore(memory.New()),
4545
extension.WithProvider("docker", dockerProv),
46-
extension.WithBasePath("/api/cp"),
46+
extension.WithBasePath("/ctrlplane"),
4747
)
4848

4949
// Use the extension with Forge

docs/content/docs/concepts/configuration.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extensions:
8686
ctrlplane:
8787
database_url: "postgres://localhost:5432/ctrlplane"
8888
default_provider: "k8s"
89-
base_path: "/api/cp"
89+
base_path: "/ctrlplane"
9090
health_interval: "30s"
9191
telemetry_flush_interval: "10s"
9292
max_instances_per_tenant: 100
@@ -101,7 +101,7 @@ In addition to the global config fields, the extension config adds:
101101
102102
| Field | Type | Description | Default |
103103
|-------|------|-------------|---------|
104-
| `base_path` | `string` | URL prefix for all ctrlplane routes | `/api/cp` |
104+
| `base_path` | `string` | URL prefix for all ctrlplane routes | `/ctrlplane` |
105105
| `disable_routes` | `bool` | Disable automatic route registration | `false` |
106106
| `disable_migrate` | `bool` | Disable automatic database migration | `false` |
107107

docs/content/docs/guides/forge-extension.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extensions:
4343
ctrlplane:
4444
database_url: "postgres://localhost:5432/ctrlplane"
4545
default_provider: "k8s"
46-
base_path: "/api/cp"
46+
base_path: "/ctrlplane"
4747
health_interval: "30s"
4848
telemetry_flush_interval: "10s"
4949
max_instances_per_tenant: 100
@@ -83,7 +83,7 @@ When `RequireConfig` is `true` and no config is found under either key, `Registe
8383
|--------|---------|
8484
| `WithAuthProvider(p)` | Set the auth provider |
8585
| `WithProvider(name, p)` | Register a cloud provider |
86-
| `WithBasePath(path)` | Set the URL prefix (default: `/api/cp`) |
86+
| `WithBasePath(path)` | Set the URL prefix (default: `/ctrlplane`) |
8787
| `WithConfig(cfg)` | Set extension configuration directly |
8888
| `WithStore(opt)` | Pass a store option to the underlying Ctrl Plane |
8989
| `WithExtension(x)` | Register a plugin extension (lifecycle hooks) |

docs/content/docs/guides/full-example.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ cpExt := extension.New(
104104
Host: dockerHost,
105105
Network: dockerNetwork,
106106
})),
107-
extension.WithBasePath("/api/cp"),
107+
extension.WithBasePath("/ctrlplane"),
108108
extension.WithAuthProvider(&auth.NoopProvider{
109109
DefaultTenantID: "default",
110110
DefaultClaims: &auth.Claims{
@@ -118,7 +118,7 @@ cpExt := extension.New(
118118
forgeApp.RegisterExtension(cpExt)
119119
```
120120

121-
The extension mounts all 50+ Ctrl Plane API routes under `/api/cp` and starts background workers for reconciliation, health checks, and telemetry collection.
121+
The extension mounts all 50+ Ctrl Plane API routes under `/ctrlplane` and starts background workers for reconciliation, health checks, and telemetry collection.
122122

123123
## Step 4: Event subscriptions
124124

@@ -229,15 +229,15 @@ Once the server is running, try these commands:
229229
curl -s http://localhost:8080/api/platform/status | jq
230230

231231
# List seeded tenants
232-
curl -s http://localhost:8080/api/cp/v1/admin/tenants | jq
232+
curl -s http://localhost:8080/ctrlplane/v1/admin/tenants | jq
233233

234234
# Create an instance
235-
curl -s -X POST http://localhost:8080/api/cp/v1/instances \
235+
curl -s -X POST http://localhost:8080/ctrlplane/v1/instances \
236236
-H "Content-Type: application/json" \
237237
-d '{"name":"my-app","provider":"docker","config":{"image":"nginx:alpine"}}' | jq
238238

239239
# List instances
240-
curl -s http://localhost:8080/api/cp/v1/instances | jq
240+
curl -s http://localhost:8080/ctrlplane/v1/instances | jq
241241

242242
# Health check
243243
curl -s http://localhost:8080/api/platform/health | jq

examples/saas-platform/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ CP_STORE=memory
4343
# ---------------------------------------------------------------------------
4444
# Ctrl Plane API base path
4545
# ---------------------------------------------------------------------------
46-
CP_BASE_PATH=/api/cp
46+
CP_BASE_PATH=/ctrlplane
4747

4848
# ---------------------------------------------------------------------------
4949
# Docker provider

examples/saas-platform/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Open the interactive API docs at [http://localhost:8080/docs](http://localhost:8
2323
| Variable | Default | Description |
2424
|----------|---------|-------------|
2525
| `CP_STORE` | `memory` | Store backend: `memory`, `bun`, `badger`, `mongo` |
26-
| `CP_BASE_PATH` | `/api/cp` | URL prefix for all Ctrl Plane routes |
26+
| `CP_BASE_PATH` | `/ctrlplane` | URL prefix for all Ctrl Plane routes |
2727
| `CP_SEED` | `true` | Create demo tenants on startup |
2828
| `CP_DOCKER_HOST` | *(auto)* | Docker daemon address |
2929
| `CP_DOCKER_NETWORK` | `bridge` | Docker network for containers |
@@ -80,7 +80,7 @@ go run ./examples/saas-platform
8080

8181
## Custom Platform Endpoints
8282

83-
In addition to the full Ctrl Plane API (under `/api/cp`), this example adds:
83+
In addition to the full Ctrl Plane API (under `/ctrlplane`), this example adds:
8484

8585
| Method | Path | Description |
8686
|--------|------|-------------|
@@ -101,13 +101,13 @@ curl -s http://localhost:8080/api/platform/status | jq
101101
### List tenants (seeded)
102102

103103
```bash
104-
curl -s http://localhost:8080/api/cp/v1/admin/tenants | jq
104+
curl -s http://localhost:8080/ctrlplane/v1/admin/tenants | jq
105105
```
106106

107107
### Create an instance
108108

109109
```bash
110-
curl -s -X POST http://localhost:8080/api/cp/v1/instances \
110+
curl -s -X POST http://localhost:8080/ctrlplane/v1/instances \
111111
-H "Content-Type: application/json" \
112112
-d '{
113113
"name": "my-app",
@@ -123,7 +123,7 @@ curl -s -X POST http://localhost:8080/api/cp/v1/instances \
123123
### List instances
124124

125125
```bash
126-
curl -s http://localhost:8080/api/cp/v1/instances | jq
126+
curl -s http://localhost:8080/ctrlplane/v1/instances | jq
127127
```
128128

129129
### Check platform health

examples/saas-platform/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func run() error {
377377
// 1. Read configuration from environment
378378
// -----------------------------------------------------------------------
379379
storeType := envOrDefault("CP_STORE", "memory")
380-
basePath := envOrDefault("CP_BASE_PATH", "/api/cp")
380+
basePath := envOrDefault("CP_BASE_PATH", "/ctrlplane")
381381
seed := envBool("CP_SEED", true)
382382
dockerHost := envOrDefault("CP_DOCKER_HOST", "")
383383
dockerNetwork := envOrDefault("CP_DOCKER_NETWORK", "bridge")

extension/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type Config struct {
4444
func DefaultConfig() Config {
4545
return Config{
4646
Config: ctrlplane.DefaultCtrlPlaneConfig(),
47-
BasePath: "/api/cp",
47+
BasePath: "/ctrlplane",
4848
}
4949
}
5050

extension/extension.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ func (e *Extension) Init(fapp forge.App) error {
152152
e.api = api.New(e.cp, fapp.Router())
153153

154154
if !e.config.DisableRoutes {
155-
e.api.RegisterRoutes(fapp.Router())
155+
basePath := e.config.BasePath
156+
if basePath == "" {
157+
basePath = "/ctrlplane"
158+
}
159+
e.api.RegisterRoutes(fapp.Router().Group(basePath))
156160
}
157161

158162
return nil

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ go 1.25.7
55
require (
66
github.com/a-h/templ v0.3.1001
77
github.com/dgraph-io/badger/v4 v4.9.1
8-
github.com/xraph/forge v1.3.1
9-
github.com/xraph/forgeui v1.3.0
10-
github.com/xraph/go-utils v1.0.0
11-
github.com/xraph/grove v1.3.0
12-
github.com/xraph/grove/drivers/mongodriver v1.3.0
13-
github.com/xraph/grove/drivers/pgdriver v1.3.0
14-
github.com/xraph/grove/drivers/sqlitedriver v1.3.0
8+
github.com/xraph/forge v1.4.0
9+
github.com/xraph/forgeui v1.4.0
10+
github.com/xraph/go-utils v1.1.0
11+
github.com/xraph/grove v1.4.0
12+
github.com/xraph/grove/drivers/mongodriver v1.4.0
13+
github.com/xraph/grove/drivers/pgdriver v1.4.0
14+
github.com/xraph/grove/drivers/sqlitedriver v1.4.0
1515
github.com/xraph/vessel v1.0.0
1616
go.jetify.com/typeid/v2 v2.0.0-alpha.3
1717
go.mongodb.org/mongo-driver/v2 v2.5.0
@@ -114,7 +114,7 @@ require (
114114
golang.org/x/sync v0.19.0 // indirect
115115
golang.org/x/sys v0.41.0 // indirect
116116
golang.org/x/term v0.39.0 // indirect
117-
golang.org/x/text v0.33.0 // indirect
117+
golang.org/x/text v0.34.0 // indirect
118118
golang.org/x/time v0.12.0 // indirect
119119
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
120120
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect

0 commit comments

Comments
 (0)