aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/http/handle.go12
-rw-r--r--cmd/http/main.go1
2 files changed, 13 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)
+}
diff --git a/cmd/http/main.go b/cmd/http/main.go
index 951c02f..8f293d4 100644
--- a/cmd/http/main.go
+++ b/cmd/http/main.go
@@ -70,6 +70,7 @@ func main() {
mux.HandleFunc("/blog/", app.blog)
mux.HandleFunc("/archive", app.archive)
mux.HandleFunc("/archive/", app.archive)
+ mux.HandleFunc("/atom.xml", app.feed)
mux.HandleFunc("/", app.home)
if *addr == ":443" {