Fix mediaType for feed.xml over gemini
This commit is contained in:
parent
8108d55c29
commit
7d48d2abba
@ -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 {
|
func postsMiddleware(tplHandler gemini.Handler) gemini.Handler {
|
||||||
|
|
||||||
return gemini.HandlerFunc(func(
|
return gemini.HandlerFunc(func(
|
||||||
@ -228,6 +240,7 @@ func (a *api) handler() (gemini.Handler, error) {
|
|||||||
mux := new(gemini.Mux)
|
mux := new(gemini.Mux)
|
||||||
mux.Handle("/posts/", postsMiddleware(tplHandler))
|
mux.Handle("/posts/", postsMiddleware(tplHandler))
|
||||||
mux.Handle("/assets/", a.assetsMiddleware())
|
mux.Handle("/assets/", a.assetsMiddleware())
|
||||||
|
mux.Handle("/feed.xml", feedMiddleware(tplHandler))
|
||||||
mux.Handle("/", tplHandler)
|
mux.Handle("/", tplHandler)
|
||||||
|
|
||||||
var h gemini.Handler
|
var h gemini.Handler
|
||||||
|
17
src/gmi/util.go
Normal file
17
src/gmi/util.go
Normal file
@ -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}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user