mirror of
https://github.com/documize/community.git
synced 2025-07-19 05:09:42 +02:00
Fix regression for robots.txt and sitemap.xml
This commit is contained in:
parent
e0e3f0c141
commit
6993dc678f
2 changed files with 18 additions and 4 deletions
|
@ -114,3 +114,17 @@ func WriteJSON(w http.ResponseWriter, v interface{}) {
|
||||||
j, _ := json.Marshal(v)
|
j, _ := json.Marshal(v)
|
||||||
w.Write(j)
|
w.Write(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteText to HTTP response
|
||||||
|
func WriteText(w http.ResponseWriter, data []byte) {
|
||||||
|
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteXML to HTTP response
|
||||||
|
func WriteXML(w http.ResponseWriter, data []byte) {
|
||||||
|
w.Header().Set("Content-Type", "application/xml; charset=utf-8")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write(data)
|
||||||
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ Disallow: /attachment/*
|
||||||
Sitemap: %s`, sitemap)
|
Sitemap: %s`, sitemap)
|
||||||
}
|
}
|
||||||
|
|
||||||
response.WriteBytes(w, []byte(robots))
|
response.WriteText(w, []byte(robots))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sitemap returns URLs that can be indexed.
|
// Sitemap returns URLs that can be indexed.
|
||||||
|
@ -205,7 +205,7 @@ func (h *Handler) Sitemap(w http.ResponseWriter, r *http.Request) {
|
||||||
t := template.Must(template.New("tmp").Parse(sitemap))
|
t := template.Must(template.New("tmp").Parse(sitemap))
|
||||||
t.Execute(buffer, &items)
|
t.Execute(buffer, &items)
|
||||||
|
|
||||||
response.WriteBytes(w, buffer.Bytes())
|
response.WriteXML(w, buffer.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
type sitemapItem struct {
|
type sitemapItem struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue