diff options
| author | Ethan Lee <ethanalee@google.com> | 2026-03-11 21:20:21 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-30 13:26:49 -0700 |
| commit | 8514eebca6ca7b3213e879faa2a83c7e9ea6e181 (patch) | |
| tree | 85db643baa162d5a828895d3655b8e1fd3f5c9af /internal/frontend | |
| parent | 46b63f3ffddc9657bc2c45fb116dc49c0b381a34 (diff) | |
| download | go-x-pkgsite-8514eebca6ca7b3213e879faa2a83c7e9ea6e181.tar.xz | |
internal/api: implement package imported-by endpoint
- Implement ServePackageImportedBy handler and GetImportedBy and GetImportedByCount datasource methods.
Change-Id: I8c4cc65fbff7172eaf48e5426e4f3f41c82bd38e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/754865
Reviewed-by: Jonathan Amsterdam <jba@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ethan Lee <ethanalee@google.com>
Diffstat (limited to 'internal/frontend')
| -rw-r--r-- | internal/frontend/imports_test.go | 6 | ||||
| -rw-r--r-- | internal/frontend/server.go | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/internal/frontend/imports_test.go b/internal/frontend/imports_test.go index bef1934c..c130a028 100644 --- a/internal/frontend/imports_test.go +++ b/internal/frontend/imports_test.go @@ -112,7 +112,7 @@ func TestFetchImportedByDetails(t *testing.T) { pkg: pkg2, wantDetails: &ImportedByDetails{ ImportedBy: []*Section{{Prefix: pkg3.Path, NumLines: 0}}, - NumImportedByDisplay: "0 (displaying 1 package, including internal and invalid packages)", + NumImportedByDisplay: "1", Total: 1, }, }, @@ -123,7 +123,7 @@ func TestFetchImportedByDetails(t *testing.T) { {Prefix: pkg2.Path, NumLines: 0}, {Prefix: pkg3.Path, NumLines: 0}, }, - NumImportedByDisplay: "0 (displaying 2 packages, including internal and invalid packages)", + NumImportedByDisplay: "2", Total: 2, }, }, @@ -161,7 +161,7 @@ func TestFetchImportedByDetails_ExceedsLimit(t *testing.T) { {Prefix: "m2.com/a/p"}, }, - NumImportedByDisplay: "0 (displaying more than 2 packages, including internal and invalid packages)", + NumImportedByDisplay: "3 (displaying more than 2 packages, including internal and invalid packages)", Total: 3, } checkFetchImportedByDetails(ctx, fds, t, m.Packages()[0], wantDetails) diff --git a/internal/frontend/server.go b/internal/frontend/server.go index 6f4e5a9d..d6a7fa01 100644 --- a/internal/frontend/server.go +++ b/internal/frontend/server.go @@ -238,6 +238,7 @@ func (s *Server) Install(handle func(string, http.Handler), cacher Cacher, authV handle("GET /vuln/", vulnHandler) handle("GET /v1/package/", s.errorHandler(api.ServePackage)) handle("GET /v1/symbols/", s.errorHandler(api.ServePackageSymbols)) + handle("GET /v1/imported-by/", s.errorHandler(api.ServePackageImportedBy)) handle("GET /v1/module/", s.errorHandler(api.ServeModule)) handle("GET /v1/versions/", s.errorHandler(api.ServeModuleVersions)) handle("GET /v1/packages/", s.errorHandler(api.ServeModulePackages)) |
