aboutsummaryrefslogtreecommitdiff
path: root/cmd/http/handle.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/http/handle.go')
-rw-r--r--cmd/http/handle.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/http/handle.go b/cmd/http/handle.go
index f5ee67a..3d49a59 100644
--- a/cmd/http/handle.go
+++ b/cmd/http/handle.go
@@ -1,8 +1,10 @@
package main
import (
+ "bytes"
"net/http"
"strings"
+ "time"
)
func (app *application) home(w http.ResponseWriter, r *http.Request) {
@@ -108,3 +110,13 @@ func (app *application) archive(w http.ResponseWriter, r *http.Request) {
}
}
}
+
+func (app application) feed(w http.ResponseWriter, r *http.Request) {
+ p, err := app.aggregate("html/blog")
+ if err != nil {
+ app.serverError(w, err)
+ }
+ w.Header().Set("Content-Type", "application/atom+xml")
+ feed := bytes.NewReader(generateFeed(r.Host, p))
+ http.ServeContent(w, r, "atom.xml", time.Now(), feed)
+}