go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/milo/frontend/view_search.go (about) 1 // Copyright 2017 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package frontend 16 17 import ( 18 "fmt" 19 "net/http" 20 21 "go.chromium.org/luci/server/router" 22 ) 23 24 // openSearchXML is the template used to serve the OpenSearch Description Document. 25 // This needs to be a template because the URL template must be a fully qualified 26 // URL with the hostname. 27 // See http://www.opensearch.org/Specifications/OpenSearch/1.1#OpenSearch_description_document 28 var openSearchXML = `<?xml version="1.0" encoding="UTF-8"?> 29 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> 30 <ShortName>LUCI</ShortName> 31 <Description> 32 Layered Universal Continuous Integration - A cloud based CI solution. 33 </Description> 34 <Url type="text/html" template="https://%s/search/?q={searchTerms}" /> 35 </OpenSearchDescription>` 36 37 // searchXMLHandler returns the opensearch document for this domain. 38 func searchXMLHandler(c *router.Context) { 39 c.Writer.Header().Set("Content-Type", "application/opensearchdescription+xml") 40 c.Writer.WriteHeader(http.StatusOK) 41 fmt.Fprintf(c.Writer, openSearchXML, c.Request.Host) 42 }