package main import ( "fmt" "net/http" "git.jlel.se/jlelse/GoBlog/pkgs/contenttype" ) func (a *goBlog) serveOpenSearch(w http.ResponseWriter, r *http.Request) { blog := r.Context().Value(blogContextKey).(string) b := a.cfg.Blogs[blog] title := b.Title sURL := a.getFullAddress(b.getRelativePath(b.Search.Path)) 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(b.Search.Path + "/opensearch.xml") } return "" }