internal: change m=json to content=json
The m=json query param that is allowed when serve stats is enabled to
changed to content=json, to avoid clashing with the m=package or
m=symbol param on the search page.
Change-Id: I5037da00323e1c721485347c6616418edb1c64fe
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/346410
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
diff --git a/internal/frontend/client.go b/internal/frontend/client.go
index 6b4710e..008af35 100644
--- a/internal/frontend/client.go
+++ b/internal/frontend/client.go
@@ -41,7 +41,7 @@
// This is only used for tests.
func (c *Client) GetVersions(pkgPath string) (_ *VersionsDetails, err error) {
defer derrors.Wrap(&err, "GetVersions(%q)", pkgPath)
- u := fmt.Sprintf("%s/%s?tab=versions&m=json", c.url, pkgPath)
+ u := fmt.Sprintf("%s/%s?tab=versions&content=json", c.url, pkgPath)
r, err := c.httpClient.Get(u)
if err != nil {
return nil, err
diff --git a/internal/frontend/unit.go b/internal/frontend/unit.go
index 6d51750..1fc7f8a 100644
--- a/internal/frontend/unit.go
+++ b/internal/frontend/unit.go
@@ -123,7 +123,7 @@
if err != nil {
return err
}
- if s.serveStats && r.FormValue("m") == "json" {
+ if s.serveStats && r.FormValue("content") == "json" {
data, err := json.Marshal(d)
if err != nil {
return fmt.Errorf("json.Marshal: %v", err)
diff --git a/internal/testing/integration/frontend_symbol_test.go b/internal/testing/integration/frontend_symbol_test.go
index aa5f0b6..acd2970 100644
--- a/internal/testing/integration/frontend_symbol_test.go
+++ b/internal/testing/integration/frontend_symbol_test.go
@@ -47,7 +47,7 @@
}
// Get frontend data.
- urlPath := fmt.Sprintf("/%s?tab=versions&m=json", test.pkgPath)
+ urlPath := fmt.Sprintf("/%s?tab=versions&content=json", test.pkgPath)
body := getFrontendPage(t, urlPath)
var vd frontend.VersionsDetails
if err := json.Unmarshal([]byte(body), &vd); err != nil {
diff --git a/internal/testing/integration/frontend_versions_test.go b/internal/testing/integration/frontend_versions_test.go
index 7f71b62..2b9f369 100644
--- a/internal/testing/integration/frontend_versions_test.go
+++ b/internal/testing/integration/frontend_versions_test.go
@@ -33,7 +33,7 @@
modulePath + "/duplicate", versionsPageMultiGoosDuplicates},
} {
t.Run(test.name, func(t *testing.T) {
- urlPath := fmt.Sprintf("/%s?tab=versions&m=json", test.pkgPath)
+ urlPath := fmt.Sprintf("/%s?tab=versions&content=json", test.pkgPath)
body := getFrontendPage(t, urlPath)
var got frontend.VersionsDetails
if err := json.Unmarshal([]byte(body), &got); err != nil {
diff --git a/tests/README.md b/tests/README.md
index 8a7eaa7..b5cba91 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -50,7 +50,7 @@
The tests compare API data for a module `tests/api/testdata` with the API
history on the frontend versions page. The frontend that is used for comparison
must have `GO_DISCOVERY_SERVE_STATS` set so that the
-`/<path>?tab=versions&m=json` endpoint is available.
+`/<path>?tab=versions&content=json` endpoint is available.
### Adding a package