diff options
| author | Christine Dodrill <me@christine.website> | 2018-07-01 13:20:01 -0700 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2018-07-01 13:20:01 -0700 |
| commit | 599712fab9127013e2d89dadabd839c847730637 (patch) | |
| tree | 2a69843e6a5fbdb69cf4c4600e5a8693a3c4a708 /rss.go | |
| parent | 7d8c210f1499bce3558f107402f2c7ccf8417e7d (diff) | |
| download | xesite-599712fab9127013e2d89dadabd839c847730637.tar.xz xesite-599712fab9127013e2d89dadabd839c847730637.zip | |
rip out mage
Diffstat (limited to 'rss.go')
| -rw-r--r-- | rss.go | 64 |
1 files changed, 0 insertions, 64 deletions
@@ -1,64 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - "time" - - "github.com/Xe/ln" -) - -var bootTime = time.Now() - -// IncrediblySecureSalt ******* -const IncrediblySecureSalt = "hunter2" - -func (s *Site) createFeed(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/rss+xml") - w.Header().Set("ETag", Hash(bootTime.String(), IncrediblySecureSalt)) - - err := s.rssFeed.WriteRss(w) - if err != nil { - http.Error(w, "Internal server error", http.StatusInternalServerError) - ln.Error(r.Context(), err, ln.F{ - "remote_addr": r.RemoteAddr, - "action": "generating_rss", - "uri": r.RequestURI, - "host": r.Host, - }) - } -} - -func (s *Site) createAtom(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/atom+xml") - w.Header().Set("ETag", Hash(bootTime.String(), IncrediblySecureSalt)) - - err := s.rssFeed.WriteAtom(w) - if err != nil { - http.Error(w, "Internal server error", http.StatusInternalServerError) - ln.Error(r.Context(), err, ln.F{ - "remote_addr": r.RemoteAddr, - "action": "generating_atom", - "uri": r.RequestURI, - "host": r.Host, - }) - } -} - -func (s *Site) createJsonFeed(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - w.Header().Set("ETag", Hash(bootTime.String(), IncrediblySecureSalt)) - - e := json.NewEncoder(w) - e.SetIndent("", "\t") - err := e.Encode(s.jsonFeed) - if err != nil { - http.Error(w, "Internal server error", http.StatusInternalServerError) - ln.Error(r.Context(), err, ln.F{ - "remote_addr": r.RemoteAddr, - "action": "generating_jsonfeed", - "uri": r.RequestURI, - "host": r.Host, - }) - } -} |
