package main import ( "bytes" "fmt" "net/http" "go.goblog.app/app/pkgs/contenttype" ) func (a *goBlog) serveOpenSearch(w http.ResponseWriter, r *http.Request) { _, b := a.getBlog(r) title := a.renderMdTitle(b.Title) sURL := a.getFullAddress(b.getRelativePath(defaultIfEmpty(b.Search.Path, defaultSearchPath))) var buf bytes.Buffer _, _ = fmt.Fprintf(&buf, ""+ "%s%s"+ ""+ "%s"+ "", title, title, sURL, sURL) w.Header().Set(contentType, "application/opensearchdescription+xml") _ = a.min.Minify(contenttype.XML, w, &buf) } func openSearchUrl(b *configBlog) string { if b.Search != nil && b.Search.Enabled { return b.getRelativePath(defaultIfEmpty(b.Search.Path, defaultSearchPath) + "/opensearch.xml") } return "" }