package main import ( "fmt" "net/http" "go.goblog.app/app/pkgs/contenttype" ) func (a *goBlog) serveOpenSearch(w http.ResponseWriter, r *http.Request) { blog := r.Context().Value(blogKey).(string) b := a.cfg.Blogs[blog] title := a.renderMdTitle(b.Title) sURL := a.getFullAddress(b.getRelativePath(defaultIfEmpty(b.Search.Path, defaultSearchPath))) xml := fmt.Sprintf(""+ "%s%s"+ ""+ "%s"+ "", title, title, sURL, sURL) w.Header().Set(contentType, "application/opensearchdescription+xml") _, _ = a.min.Write(w, contenttype.XML, []byte(xml)) } func openSearchUrl(b *configBlog) string { if b.Search != nil && b.Search.Enabled { return b.getRelativePath(defaultIfEmpty(b.Search.Path, defaultSearchPath) + "/opensearch.xml") } return "" }