summaryrefslogtreecommitdiff
path: root/internal/serve/serve.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/serve/serve.go')
-rw-r--r--internal/serve/serve.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/serve/serve.go b/internal/serve/serve.go
index 0b3b340..396babe 100644
--- a/internal/serve/serve.go
+++ b/internal/serve/serve.go
@@ -23,6 +23,16 @@ type Options struct {
// secret in the URL is the mechanism that actually works with them. Anyone
// holding the URL holds the access.
Token string
+
+ // AllowIngest enables /manifest and /ingest, letting `podkit push` upload
+ // episodes from elsewhere. Off by default: a feed host that also accepts
+ // writes is a different security proposition from one that only reads.
+ AllowIngest bool
+
+ // Rebuild regenerates feed.xml after an upload. Injected rather than built
+ // here so the server does not need to know the feed's metadata, and so the
+ // ingest path is testable without a real feed.
+ Rebuild func() error
}
// NewToken returns a random token suitable for Options.Token.
@@ -45,6 +55,11 @@ func Handler(opts Options) http.Handler {
http.ServeFile(w, r, path.Join(opts.Dir, "feed.xml"))
})
+ if opts.AllowIngest {
+ mux.HandleFunc("/manifest", handleManifest(opts.Dir))
+ mux.HandleFunc("/ingest", handleIngest(opts.Dir, opts.Rebuild))
+ }
+
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)