1
0
Fork 0
miniflux/api/opml.go

38 lines
940 B
Go
Raw Normal View History

2018-04-29 21:56:40 -04:00
// Copyright 2018 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
2018-08-25 00:51:50 -04:00
package api // import "miniflux.app/api"
2018-04-29 21:56:40 -04:00
import (
"net/http"
2018-09-03 17:26:40 -04:00
"miniflux.app/http/request"
2018-08-25 00:51:50 -04:00
"miniflux.app/http/response/json"
"miniflux.app/http/response/xml"
"miniflux.app/reader/opml"
2018-04-29 21:56:40 -04:00
)
func (h *handler) exportFeeds(w http.ResponseWriter, r *http.Request) {
opmlHandler := opml.NewHandler(h.store)
2018-09-03 17:26:40 -04:00
opml, err := opmlHandler.Export(request.UserID(r))
2018-04-29 21:56:40 -04:00
if err != nil {
2018-10-07 21:42:43 -04:00
json.ServerError(w, r, err)
2018-04-29 21:56:40 -04:00
return
}
2018-10-07 21:42:43 -04:00
xml.OK(w, r, opml)
2018-04-29 21:56:40 -04:00
}
func (h *handler) importFeeds(w http.ResponseWriter, r *http.Request) {
opmlHandler := opml.NewHandler(h.store)
2018-09-03 17:26:40 -04:00
err := opmlHandler.Import(request.UserID(r), r.Body)
2018-04-29 21:56:40 -04:00
defer r.Body.Close()
if err != nil {
2018-10-07 21:42:43 -04:00
json.ServerError(w, r, err)
2018-04-29 21:56:40 -04:00
return
}
2018-10-07 21:42:43 -04:00
json.Created(w, r, map[string]string{"message": "Feeds imported successfully"})
2018-04-29 21:56:40 -04:00
}