Add workspace membership roles with serialized permission changes
Foundry Go checks / check (push) Successful in 1m38s
Foundry Go checks / check (pull_request) Successful in 1m43s

This commit is contained in:
2026-11-05 18:19:19 +08:00
parent e626a2359e
commit 53c4dbee8e
2 changed files with 245 additions and 0 deletions
+6
View File
@@ -86,6 +86,8 @@ func (s *service) protected(callbacks map[string]string, handle endpoint) http.H
switch {
case errors.Is(err, sql.ErrNoRows):
reject(w, 404, "not_found")
case errors.As(err, &pg) && (pg.Code == "22P02" || pg.Code == "23503" || pg.Code == "23514"):
reject(w, 400, "invalid_reference")
case errors.As(err, &pg) && pg.Code == "23505":
reject(w, 409, "already_exists")
default:
@@ -98,6 +100,10 @@ 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}
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))
mux.HandleFunc("/projects/{project}/workspaces/{workspace}/members/{account}", s.protected(callbacks, s.member))
mux.HandleFunc("/projects/{project}/profile", s.protected(callbacks, s.profile))
}