summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gmi/gmi.go13
-rw-r--r--src/gmi/util.go17
2 files changed, 30 insertions, 0 deletions
diff --git a/src/gmi/gmi.go b/src/gmi/gmi.go
index c2a32aa..115f379 100644
--- a/src/gmi/gmi.go
+++ b/src/gmi/gmi.go
@@ -161,6 +161,18 @@ func indexMiddleware(h gemini.Handler) gemini.Handler {
})
}
+func feedMiddleware(h gemini.Handler) gemini.Handler {
+
+ return gemini.HandlerFunc(func(
+ ctx context.Context,
+ rw gemini.ResponseWriter,
+ r *gemini.Request,
+ ) {
+ rw = forceResponseWriterMediaType(rw, "application/atom+xml")
+ h.ServeGemini(ctx, rw, r)
+ })
+}
+
func postsMiddleware(tplHandler gemini.Handler) gemini.Handler {
return gemini.HandlerFunc(func(
@@ -228,6 +240,7 @@ func (a *api) handler() (gemini.Handler, error) {
mux := new(gemini.Mux)
mux.Handle("/posts/", postsMiddleware(tplHandler))
mux.Handle("/assets/", a.assetsMiddleware())
+ mux.Handle("/feed.xml", feedMiddleware(tplHandler))
mux.Handle("/", tplHandler)
var h gemini.Handler
diff --git a/src/gmi/util.go b/src/gmi/util.go
new file mode 100644
index 0000000..b632a54
--- /dev/null
+++ b/src/gmi/util.go
@@ -0,0 +1,17 @@
+package gmi
+
+import "git.sr.ht/~adnano/go-gemini"
+
+type rwSetMediaTypeNoop struct {
+ gemini.ResponseWriter
+}
+
+func (rwSetMediaTypeNoop) SetMediaType(string) {}
+
+func forceResponseWriterMediaType(
+ rw gemini.ResponseWriter, mediaType string,
+) gemini.ResponseWriter {
+
+ rw.SetMediaType(mediaType)
+ return rwSetMediaTypeNoop{rw}
+}