aboutsummaryrefslogtreecommitdiff
path: root/internal/frontend
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2024-09-27 14:21:54 -0400
committerJonathan Amsterdam <jba@google.com>2024-09-30 19:34:39 +0000
commite87f2996afaa10346757d867b760f33bac42be6b (patch)
tree60a29293211eece06a5265e30562e5a0683d4f87 /internal/frontend
parent2d793c01b28955c4626cf3fce6621660d009d5b1 (diff)
downloadgo-x-pkgsite-e87f2996afaa10346757d867b760f33bac42be6b.tar.xz
internal/frontend: require GET for most routes
Add a GET method to the patterns for most frontend routes. We omitted a few where we're not totally clear on what the client may be sending. Change-Id: I3f300b7d3753fd4009a60855c7a15b24c5e27dd6 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/616395 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/frontend')
-rw-r--r--internal/frontend/server.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 820e5dc4..ccc69092 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -180,37 +180,37 @@ func (s *Server) Install(handle func(string, http.Handler), cacher Cacher, authV
// https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#startup
// and for /_ah/warmup at
// https://cloud.google.com/appengine/docs/standard/go/configuring-warmup-requests.
- handle("/_ah/", http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
+ handle("GET /_ah/", http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) {
log.Infof(r.Context(), "Request made to %q", r.URL.Path)
}))
- handle("/static/", s.staticHandler())
- handle("/third_party/", http.StripPrefix("/third_party", http.FileServer(http.FS(s.thirdPartyFS))))
- handle("/favicon.ico", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ handle("GET /static/", s.staticHandler())
+ handle("GET /third_party/", http.StripPrefix("/third_party", http.FileServer(http.FS(s.thirdPartyFS))))
+ handle("GET /favicon.ico", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
serveFileFS(w, r, s.staticFS, "shared/icon/favicon.ico")
}))
handle("/sitemap/", http.StripPrefix("/sitemap/", http.FileServer(http.Dir("private/sitemap"))))
- handle("/mod/", http.HandlerFunc(s.handleModuleDetailsRedirect))
- handle("/pkg/", http.HandlerFunc(s.handlePackageDetailsRedirect))
+ handle("GET /mod/", http.HandlerFunc(s.handleModuleDetailsRedirect))
+ handle("GET /pkg/", http.HandlerFunc(s.handlePackageDetailsRedirect))
if fetchHandler != nil {
handle("/fetch/", fetchHandler)
}
handle("/play/compile", http.HandlerFunc(s.proxyPlayground))
- handle("/play/fmt", http.HandlerFunc(s.handleFmt))
+ handle("GET /play/fmt", http.HandlerFunc(s.handleFmt))
handle("/play/share", http.HandlerFunc(s.proxyPlayground))
- handle("/search", searchHandler)
- handle("/search-help", s.staticPageHandler("search-help", "Search Help"))
- handle("/license-policy", s.licensePolicyHandler())
- handle("/about", s.staticPageHandler("about", "About"))
- handle("/badge/", http.HandlerFunc(s.badgeHandler))
- handle("/C", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ handle("GET /search", searchHandler)
+ handle("GET /search-help", s.staticPageHandler("search-help", "Search Help"))
+ handle("GET /license-policy", s.licensePolicyHandler())
+ handle("GET /about", s.staticPageHandler("about", "About"))
+ handle("GET /badge/", http.HandlerFunc(s.badgeHandler))
+ handle("GET /C", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Package "C" is a special case: redirect to /cmd/cgo.
// (This is what golang.org/C does.)
http.Redirect(w, r, "/cmd/cgo", http.StatusMovedPermanently)
}))
- handle("/golang.org/x", s.staticPageHandler("subrepo", "Sub-repositories"))
- handle("/files/", http.StripPrefix("/files", s.fileMux))
- handle("/vuln/", vulnHandler)
+ handle("GET /golang.org/x", s.staticPageHandler("subrepo", "Sub-repositories"))
+ handle("GET /files/", http.StripPrefix("/files", s.fileMux))
+ handle("GET /vuln/", vulnHandler)
handle("/opensearch.xml", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
serveFileFS(w, r, s.staticFS, "shared/opensearch.xml")
}))
@@ -234,8 +234,8 @@ Sitemap: https://pkg.go.dev/sitemap/index.xml
// installDebugHandlers installs handlers for debugging. Most of the handlers
// are provided by the net/http/pprof package. Although that package installs
-// them on the default ServeMux in its init function, we must install them on
-// our own ServeMux.
+// them on the default ServeMux in its init function, we must install them
+// on our own ServeMux.
func (s *Server) installDebugHandlers(handle func(string, http.Handler)) {
ifDebug := func(h func(http.ResponseWriter, *http.Request)) http.HandlerFunc {