CAT-G1, G2: the forge's Go bundle serves both package seats' verbs into its package registry, for both packages

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 13:43:59 +01:00
parent ede8994799
commit f16efbef4f
18 changed files with 658 additions and 29 deletions
+17 -8
View File
@@ -1,5 +1,5 @@
// Package forgehttp is the forge's HTTP interface as this module's Go bundles reach it (cmd/forge,
// cmd/npm-registry), on the forge's own machine. One copy for both bundles (novox/hq issue 539).
// cmd/package-registry), on the forge's own machine. One copy for both bundles (novox/hq issue 539).
//
// Two ways in, by what the manifest hands the bundle:
//
@@ -148,12 +148,21 @@ func (c *Client) authorize(req *http.Request) error {
// 404 is ErrNotFound. One byte past the limit is read, so a body the limit cut is told from one that fits it
// exactly: a cut body is refused, never read as if it were whole.
func (c *Client) Do(ctx context.Context, method, path string, payload any, limit int64) ([]byte, error) {
if payload == nil {
return c.Send(ctx, method, path, nil, "", limit)
}
raw, err := json.Marshal(payload)
if err != nil {
return nil, err
}
return c.Send(ctx, method, path, raw, "application/json", limit)
}
// Send is Do with a body of its own content type, sent as it is (a package's file uploaded into the registry);
// a nil body sends none.
func (c *Client) Send(ctx context.Context, method, path string, raw []byte, contentType string, limit int64) ([]byte, error) {
var body io.Reader
if payload != nil {
raw, err := json.Marshal(payload)
if err != nil {
return nil, err
}
if raw != nil {
body = bytes.NewReader(raw)
}
req, err := http.NewRequestWithContext(ctx, method, c.URL+path, body)
@@ -164,8 +173,8 @@ func (c *Client) Do(ctx context.Context, method, path string, payload any, limit
return nil, err
}
req.Header.Set("Accept", "application/json")
if payload != nil {
req.Header.Set("Content-Type", "application/json")
if raw != nil {
req.Header.Set("Content-Type", contentType)
}
res, err := c.client().Do(req)
if err != nil {