Add configurable onboarding and scoped invitation links
Foundry Go checks / check (push) Successful in 1m47s
Foundry Go checks / check (pull_request) Successful in 1m57s

This commit is contained in:
2026-11-05 18:24:30 +08:00
parent 53c4dbee8e
commit 1b756d36ce
9 changed files with 624 additions and 11 deletions
+11 -3
View File
@@ -16,7 +16,10 @@ import (
)
type service struct {
db *sql.DB
db *sql.DB
origin string
callbacks map[string]string
onboardingConfigs map[string]OnboardingConfig
}
type response map[string]any
@@ -98,8 +101,13 @@ func (s *service) protected(callbacks map[string]string, handle endpoint) http.H
}
}
func Register(mux *http.ServeMux, db *sql.DB, callbacks map[string]string) {
s := &service{db: db}
func Register(mux *http.ServeMux, db *sql.DB, callbacks map[string]string, origin string, configs map[string]OnboardingConfig) {
s := &service{db: db, origin: origin, callbacks: callbacks, onboardingConfigs: configs}
mux.HandleFunc("/projects/{project}/onboarding", s.protected(callbacks, s.onboarding))
mux.HandleFunc("/s/{token}", s.shortLink)
mux.HandleFunc("/projects/{project}/shares/redeem", s.protected(callbacks, s.redeemShare))
mux.HandleFunc("/projects/{project}/workspaces/{workspace}/shares", s.protected(callbacks, s.shares))
mux.HandleFunc("/projects/{project}/workspaces/{workspace}/shares/{link}", s.protected(callbacks, s.revokeShare))
mux.HandleFunc("/projects/{project}/workspaces", s.protected(callbacks, s.workspaces))
mux.HandleFunc("/projects/{project}/workspaces/{workspace}", s.protected(callbacks, s.workspace))
mux.HandleFunc("/projects/{project}/workspaces/{workspace}/members", s.protected(callbacks, s.members))