diff --git a/internal/frontend/server.go b/internal/frontend/server.go index cd768a62f..794a55988 100644 --- a/internal/frontend/server.go +++ b/internal/frontend/server.go @@ -193,6 +193,7 @@ Disallow: /fetch/* Sitemap: https://pkg.go.dev/sitemap/index.xml `)) })) + handle("/opensearch.xml", s.opensearchHandler()) s.installDebugHandlers(handle) } @@ -466,6 +467,21 @@ func (s *Server) aboutHandler() http.HandlerFunc { }) } +func (s *Server) opensearchHandler() http.HandlerFunc { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/opensearchdescription+xml") + http.ServeContent(w, r, "", time.Time{}, strings.NewReader(` + + UTF-8 + Go Packages + Go Packages: Go Package Documentation + + + +`)) + }) +} + // newBasePage returns a base page for the given request and title. func (s *Server) newBasePage(r *http.Request, title string) basePage { q := rawSearchQuery(r) diff --git a/static/frontend/frontend.tmpl b/static/frontend/frontend.tmpl index 3d118a08b..ecb942ea7 100644 --- a/static/frontend/frontend.tmpl +++ b/static/frontend/frontend.tmpl @@ -30,6 +30,7 @@ {{block "canonical" .}}{{end}} + {{block "title" .}} Go Packages {{end}}