mirror of
https://github.com/git-pkgs/proxy.git
synced 2026-06-02 08:38:17 -04:00
* Structured JSON error responses for API endpoints
API handlers returned errors via http.Error (text/plain) with ad-hoc
strings, while the mirror API used a different {"error": "..."} shape
and leaked internal err.Error() text to clients.
Add ErrorResponse{Code, Message} with stable codes (BAD_REQUEST,
NOT_FOUND, UPSTREAM_ERROR, INTERNAL_ERROR) and writeError/badRequest/
notFound/internalError helpers. Convert all JSON API handlers in
api.go, browse.go, mirror_api.go and the /stats endpoint. Enrichment
failures now report 502 UPSTREAM_ERROR rather than 500.
Protocol handlers in internal/handler/ are deliberately unchanged
since npm/pip/cargo clients expect their own response formats, not
JSON. HTML page handlers in server.go also keep text/plain.
Swagger @Failure annotations updated and docs regenerated.
Fixes #76
* Convert validatePackagePath errors to JSON in API handlers
|
||
|---|---|---|
| .. | ||
| static | ||
| templates | ||
| api.go | ||
| api_test.go | ||
| browse.go | ||
| browse_bench_test.go | ||
| browse_test.go | ||
| dashboard.go | ||
| errors.go | ||
| errors_test.go | ||
| eviction.go | ||
| eviction_test.go | ||
| middleware.go | ||
| middleware_test.go | ||
| mirror_api.go | ||
| mirror_api_test.go | ||
| packages_list_test.go | ||
| resolve.go | ||
| resolve_test.go | ||
| server.go | ||
| server_test.go | ||
| static.go | ||
| swagger_gen.go | ||
| templates.go | ||
| templates_test.go | ||