diff options
Diffstat (limited to 'api/feed.go')
-rw-r--r-- | api/feed.go | 14 |
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() |