sitemap.go 746 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2018 Gitote. All rights reserved.
  3. //
  4. // This source code is licensed under the MIT license found in the
  5. // LICENSE file in the root directory of this source tree.
  6. package user
  7. import (
  8. "encoding/xml"
  9. "net/http"
  10. )
  11. type Urlset struct {
  12. Loc string `xml:"url>loc"`
  13. Changefreq string `xml:"url>changefreq"`
  14. Priority string `xml:"url>priority"`
  15. }
  16. func Sitemap(w http.ResponseWriter, r *http.Request) {
  17. profile := Urlset{"https://gitote.in/", "Daily", "1.0"}
  18. x, err := xml.MarshalIndent(profile, "", " ")
  19. if err != nil {
  20. http.Error(w, err.Error(), http.StatusInternalServerError)
  21. return
  22. }
  23. w.Header().Set("Content-Type", "application/xml")
  24. w.Write(x)
  25. }