aboutsummaryrefslogtreecommitdiffhomepage
path: root/api
diff options
context:
space:
mode:
authorGravatar Rogier Lommers <rogier@lommers.org>2018-01-12 22:42:36 +0100
committerGravatar fguillot <fred@kanboard.net>2018-01-12 13:42:36 -0800
commit4aec2453f442277c858bab99ae4d0a6cba857a10 (patch)
tree04895640d061a3f4c728748467d70f4c6cdc4cc4 /api
parent9652dfa1feccd15bbb56d61281f148f71afcb800 (diff)
Add API endpoint for OPML export
Diffstat (limited to 'api')
-rw-r--r--api/feed.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/api/feed.go b/api/feed.go
index c3fc048..16e3d7d 100644
--- a/api/feed.go
+++ b/api/feed.go
@@ -7,6 +7,8 @@ package api
import (
"errors"
+ "github.com/miniflux/miniflux/reader/opml"
+
"github.com/miniflux/miniflux/http/handler"
)
@@ -132,6 +134,18 @@ func (c *Controller) GetFeeds(ctx *handler.Context, request *handler.Request, re
response.JSON().Standard(feeds)
}
+// Export is the API handler that incoves an OPML export.
+func (c *Controller) Export(ctx *handler.Context, request *handler.Request, response *handler.Response) {
+ opmlHandler := opml.NewHandler(c.store)
+
+ opml, err := opmlHandler.Export(ctx.LoggedUser().ID)
+ if err != nil {
+ response.JSON().ServerError(errors.New("unable to export feeds to OPML"))
+ }
+
+ response.XML().Serve(opml)
+}
+
// GetFeed is the API handler to get a feed.
func (c *Controller) GetFeed(ctx *handler.Context, request *handler.Request, response *handler.Response) {
userID := ctx.UserID()