|
|
@@ -14,9 +14,7 @@ import (
|
|
|
"miniflux.app/v2/internal/config"
|
|
|
"miniflux.app/v2/internal/http/request"
|
|
|
"miniflux.app/v2/internal/http/response"
|
|
|
- "miniflux.app/v2/internal/http/route"
|
|
|
"miniflux.app/v2/internal/integration"
|
|
|
- "miniflux.app/v2/internal/mediaproxy"
|
|
|
"miniflux.app/v2/internal/model"
|
|
|
"miniflux.app/v2/internal/proxyrotator"
|
|
|
"miniflux.app/v2/internal/reader/fetcher"
|
|
|
@@ -25,15 +23,8 @@ import (
|
|
|
"miniflux.app/v2/internal/storage"
|
|
|
"miniflux.app/v2/internal/urllib"
|
|
|
"miniflux.app/v2/internal/validator"
|
|
|
-
|
|
|
- "github.com/gorilla/mux"
|
|
|
)
|
|
|
|
|
|
-type handler struct {
|
|
|
- store *storage.Storage
|
|
|
- router *mux.Router
|
|
|
-}
|
|
|
-
|
|
|
var (
|
|
|
errEmptyFeedTitle = errors.New("googlereader: empty feed title")
|
|
|
errFeedNotFound = errors.New("googlereader: feed not found")
|
|
|
@@ -41,96 +32,47 @@ var (
|
|
|
errSimultaneously = fmt.Errorf("googlereader: %s and %s should not be supplied simultaneously", keptUnreadStreamSuffix, readStreamSuffix)
|
|
|
)
|
|
|
|
|
|
-// Serve handles Google Reader API calls.
|
|
|
-func Serve(router *mux.Router, store *storage.Storage) {
|
|
|
- handler := &handler{store, router}
|
|
|
- router.HandleFunc("/accounts/ClientLogin", handler.clientLoginHandler).Methods(http.MethodPost).Name("ClientLogin")
|
|
|
-
|
|
|
- middleware := newMiddleware(store)
|
|
|
- sr := router.PathPrefix("/reader/api/0").Subrouter()
|
|
|
- sr.Use(middleware.apiKeyAuth)
|
|
|
- sr.HandleFunc("/token", handler.tokenHandler).Methods(http.MethodGet).Name("Token")
|
|
|
- sr.HandleFunc("/edit-tag", handler.editTagHandler).Methods(http.MethodPost).Name("EditTag")
|
|
|
- sr.HandleFunc("/rename-tag", handler.renameTagHandler).Methods(http.MethodPost).Name("Rename Tag")
|
|
|
- sr.HandleFunc("/disable-tag", handler.disableTagHandler).Methods(http.MethodPost).Name("Disable Tag")
|
|
|
- sr.HandleFunc("/tag/list", handler.tagListHandler).Methods(http.MethodGet).Name("TagList")
|
|
|
- sr.HandleFunc("/user-info", handler.userInfoHandler).Methods(http.MethodGet).Name("UserInfo")
|
|
|
- sr.HandleFunc("/subscription/list", handler.subscriptionListHandler).Methods(http.MethodGet).Name("SubscriptonList")
|
|
|
- sr.HandleFunc("/subscription/edit", handler.editSubscriptionHandler).Methods(http.MethodPost).Name("SubscriptionEdit")
|
|
|
- sr.HandleFunc("/subscription/quickadd", handler.quickAddHandler).Methods(http.MethodPost).Name("QuickAdd")
|
|
|
- sr.HandleFunc("/stream/items/ids", handler.streamItemIDsHandler).Methods(http.MethodGet).Name("StreamItemIDs")
|
|
|
- sr.HandleFunc("/stream/items/contents", handler.streamItemContentsHandler).Methods(http.MethodPost).Name("StreamItemsContents")
|
|
|
- sr.HandleFunc("/mark-all-as-read", handler.markAllAsReadHandler).Methods(http.MethodPost).Name("MarkAllAsRead")
|
|
|
- sr.PathPrefix("/").HandlerFunc(handler.serveHandler).Methods(http.MethodPost, http.MethodGet).Name("GoogleReaderApiEndpoint")
|
|
|
+// NewHandler returns an http.Handler that handles Google Reader API calls.
|
|
|
+// The returned handler expects the base path to be stripped from the request URL.
|
|
|
+func NewHandler(store *storage.Storage, rewriteContent func(string) string, proxifyEnclosures func(model.EnclosureList)) http.Handler {
|
|
|
+ h := &greaderHandler{
|
|
|
+ store: store,
|
|
|
+ rewriteContent: rewriteContent,
|
|
|
+ proxifyEnclosures: proxifyEnclosures,
|
|
|
+ }
|
|
|
+
|
|
|
+ authMiddleware := newAuthMiddleware(store)
|
|
|
+ withApiKeyAuth := func(fn http.HandlerFunc) http.Handler {
|
|
|
+ return authMiddleware.validateApiKey(fn)
|
|
|
+ }
|
|
|
+
|
|
|
+ mux := http.NewServeMux()
|
|
|
+ mux.HandleFunc("POST /accounts/ClientLogin", h.clientLoginHandler)
|
|
|
+ mux.Handle("GET /reader/api/0/token", withApiKeyAuth(h.tokenHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/edit-tag", withApiKeyAuth(h.editTagHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/rename-tag", withApiKeyAuth(h.renameTagHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/disable-tag", withApiKeyAuth(h.disableTagHandler))
|
|
|
+ mux.Handle("GET /reader/api/0/tag/list", withApiKeyAuth(h.tagListHandler))
|
|
|
+ mux.Handle("GET /reader/api/0/user-info", withApiKeyAuth(h.userInfoHandler))
|
|
|
+ mux.Handle("GET /reader/api/0/subscription/list", withApiKeyAuth(h.subscriptionListHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/subscription/edit", withApiKeyAuth(h.editSubscriptionHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/subscription/quickadd", withApiKeyAuth(h.quickAddHandler))
|
|
|
+ mux.Handle("GET /reader/api/0/stream/items/ids", withApiKeyAuth(h.streamItemIDsHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/stream/items/contents", withApiKeyAuth(h.streamItemContentsHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/mark-all-as-read", withApiKeyAuth(h.markAllAsReadHandler))
|
|
|
+ mux.Handle("GET /reader/api/0/", withApiKeyAuth(h.fallbackHandler))
|
|
|
+ mux.Handle("POST /reader/api/0/", withApiKeyAuth(h.fallbackHandler))
|
|
|
+
|
|
|
+ return mux
|
|
|
}
|
|
|
|
|
|
-func checkAndSimplifyTags(addTags []Stream, removeTags []Stream) (map[StreamType]bool, error) {
|
|
|
- tags := make(map[StreamType]bool)
|
|
|
- for _, s := range addTags {
|
|
|
- switch s.Type {
|
|
|
- case ReadStream:
|
|
|
- if _, ok := tags[KeptUnreadStream]; ok {
|
|
|
- return nil, errSimultaneously
|
|
|
- }
|
|
|
- tags[ReadStream] = true
|
|
|
- case KeptUnreadStream:
|
|
|
- if _, ok := tags[ReadStream]; ok {
|
|
|
- return nil, errSimultaneously
|
|
|
- }
|
|
|
- tags[ReadStream] = false
|
|
|
- case StarredStream:
|
|
|
- tags[StarredStream] = true
|
|
|
- case BroadcastStream, LikeStream:
|
|
|
- slog.Debug("Broadcast & Like tags are not implemented!")
|
|
|
- default:
|
|
|
- return nil, fmt.Errorf("googlereader: unsupported tag type: %s", s.Type)
|
|
|
- }
|
|
|
- }
|
|
|
- for _, s := range removeTags {
|
|
|
- switch s.Type {
|
|
|
- case ReadStream:
|
|
|
- if _, ok := tags[ReadStream]; ok {
|
|
|
- return nil, errSimultaneously
|
|
|
- }
|
|
|
- tags[ReadStream] = false
|
|
|
- case KeptUnreadStream:
|
|
|
- if _, ok := tags[ReadStream]; ok {
|
|
|
- return nil, errSimultaneously
|
|
|
- }
|
|
|
- tags[ReadStream] = true
|
|
|
- case StarredStream:
|
|
|
- if _, ok := tags[StarredStream]; ok {
|
|
|
- return nil, fmt.Errorf("googlereader: %s should not be supplied for add and remove simultaneously", starredStreamSuffix)
|
|
|
- }
|
|
|
- tags[StarredStream] = false
|
|
|
- case BroadcastStream, LikeStream:
|
|
|
- slog.Debug("Broadcast & Like tags are not implemented!")
|
|
|
- default:
|
|
|
- return nil, fmt.Errorf("googlereader: unsupported tag type: %s", s.Type)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return tags, nil
|
|
|
-}
|
|
|
-
|
|
|
-func checkOutputFormat(r *http.Request) error {
|
|
|
- var output string
|
|
|
- if r.Method == http.MethodPost {
|
|
|
- err := r.ParseForm()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
- output = r.Form.Get("output")
|
|
|
- } else {
|
|
|
- output = request.QueryStringParam(r, "output", "")
|
|
|
- }
|
|
|
- if output != "json" {
|
|
|
- return errors.New("googlereader: only json output is supported")
|
|
|
- }
|
|
|
- return nil
|
|
|
+type greaderHandler struct {
|
|
|
+ store *storage.Storage
|
|
|
+ rewriteContent func(string) string
|
|
|
+ proxifyEnclosures func(model.EnclosureList)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) clientLoginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) clientLoginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
slog.Debug("[GoogleReader] Handle /accounts/ClientLogin",
|
|
|
@@ -207,7 +149,7 @@ func (h *handler) clientLoginHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.Text(w, r, result.String())
|
|
|
}
|
|
|
|
|
|
-func (h *handler) tokenHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) tokenHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
slog.Debug("[GoogleReader] Handle /token",
|
|
|
@@ -245,7 +187,7 @@ func (h *handler) tokenHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.Text(w, r, token)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) editTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) editTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -382,7 +324,7 @@ func (h *handler) editTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.Text(w, r, "OK")
|
|
|
}
|
|
|
|
|
|
-func (h *handler) quickAddHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) quickAddHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -577,14 +519,14 @@ func move(feedStream Stream, labelStream Stream, store *storage.Storage, userID
|
|
|
return store.UpdateFeed(feed)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) feedIconURL(f *model.Feed) string {
|
|
|
+func (h *greaderHandler) feedIconURL(f *model.Feed) string {
|
|
|
if f.Icon != nil && f.Icon.ExternalIconID != "" {
|
|
|
- return config.Opts.RootURL() + route.Path(h.router, "feedIcon", "externalIconID", f.Icon.ExternalIconID)
|
|
|
+ return config.Opts.BaseURL() + "/feed/icon/" + f.Icon.ExternalIconID
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
-func (h *handler) editSubscriptionHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) editSubscriptionHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -663,7 +605,7 @@ func (h *handler) editSubscriptionHandler(w http.ResponseWriter, r *http.Request
|
|
|
response.Text(w, r, "OK")
|
|
|
}
|
|
|
|
|
|
-func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) streamItemContentsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
userName := request.UserName(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
@@ -729,7 +671,7 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
|
|
|
Title: "Reading List",
|
|
|
Updated: time.Now().Unix(),
|
|
|
Self: []contentHREF{{
|
|
|
- HREF: config.Opts.RootURL() + route.Path(h.router, "StreamItemsContents"),
|
|
|
+ HREF: config.Opts.BaseURL() + "/reader/api/0/stream/items/contents",
|
|
|
}},
|
|
|
Author: userName,
|
|
|
Items: make([]contentItem, len(entries)),
|
|
|
@@ -754,8 +696,8 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
|
|
|
categories = append(categories, userStarred)
|
|
|
}
|
|
|
|
|
|
- entry.Content = mediaproxy.RewriteDocumentWithAbsoluteProxyURL(h.router, entry.Content)
|
|
|
- entry.Enclosures.ProxifyEnclosureURL(h.router, config.Opts.MediaProxyMode(), config.Opts.MediaProxyResourceTypes())
|
|
|
+ entry.Content = h.rewriteContent(entry.Content)
|
|
|
+ h.proxifyEnclosures(entry.Enclosures)
|
|
|
|
|
|
result.Items[i] = contentItem{
|
|
|
ID: convertEntryIDToLongFormItemID(entry.ID),
|
|
|
@@ -797,7 +739,7 @@ func (h *handler) streamItemContentsHandler(w http.ResponseWriter, r *http.Reque
|
|
|
response.JSON(w, r, result)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) disableTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) disableTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -838,7 +780,7 @@ func (h *handler) disableTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.Text(w, r, "OK")
|
|
|
}
|
|
|
|
|
|
-func (h *handler) renameTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) renameTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -905,7 +847,7 @@ func (h *handler) renameTagHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.Text(w, r, "OK")
|
|
|
}
|
|
|
|
|
|
-func (h *handler) tagListHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) tagListHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -941,7 +883,7 @@ func (h *handler) tagListHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.JSON(w, r, result)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) subscriptionListHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) subscriptionListHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -978,7 +920,7 @@ func (h *handler) subscriptionListHandler(w http.ResponseWriter, r *http.Request
|
|
|
response.JSON(w, r, result)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) serveHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) fallbackHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
slog.Debug("[GoogleReader] API endpoint not implemented yet",
|
|
|
@@ -990,7 +932,7 @@ func (h *handler) serveHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.JSON(w, r, []string{})
|
|
|
}
|
|
|
|
|
|
-func (h *handler) userInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) userInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
slog.Debug("[GoogleReader] Handle /user-info",
|
|
|
@@ -1013,7 +955,7 @@ func (h *handler) userInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
response.JSON(w, r, userInfo)
|
|
|
}
|
|
|
|
|
|
-func (h *handler) streamItemIDsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) streamItemIDsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -1066,7 +1008,7 @@ func (h *handler) streamItemIDsHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func (h *handler) handleReadingListStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
+func (h *greaderHandler) handleReadingListStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
slog.Debug("[GoogleReader] Handle ReadingListStream",
|
|
|
@@ -1109,7 +1051,7 @@ func (h *handler) handleReadingListStreamHandler(w http.ResponseWriter, r *http.
|
|
|
response.JSON(w, r, streamIDResponse{itemRefs, continuation})
|
|
|
}
|
|
|
|
|
|
-func (h *handler) handleStarredStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
+func (h *greaderHandler) handleStarredStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
builder := h.store.NewEntryQueryBuilder(rm.UserID)
|
|
|
builder.WithoutStatus(model.EntryStatusRemoved)
|
|
|
builder.WithStarred(true)
|
|
|
@@ -1130,7 +1072,7 @@ func (h *handler) handleStarredStreamHandler(w http.ResponseWriter, r *http.Requ
|
|
|
response.JSON(w, r, streamIDResponse{itemRefs, continuation})
|
|
|
}
|
|
|
|
|
|
-func (h *handler) handleReadStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
+func (h *greaderHandler) handleReadStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
builder := h.store.NewEntryQueryBuilder(rm.UserID)
|
|
|
builder.WithoutStatus(model.EntryStatusRemoved)
|
|
|
builder.WithStatus(model.EntryStatusRead)
|
|
|
@@ -1174,7 +1116,7 @@ func getItemRefsAndContinuation(builder storage.EntryQueryBuilder, rm requestMod
|
|
|
return itemRefs, continuation, nil
|
|
|
}
|
|
|
|
|
|
-func (h *handler) handleFeedStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
+func (h *greaderHandler) handleFeedStreamHandler(w http.ResponseWriter, r *http.Request, rm requestModifiers) {
|
|
|
feedID, err := strconv.ParseInt(rm.Streams[0].ID, 10, 64)
|
|
|
if err != nil {
|
|
|
response.JSONServerError(w, r, err)
|
|
|
@@ -1211,7 +1153,7 @@ func (h *handler) handleFeedStreamHandler(w http.ResponseWriter, r *http.Request
|
|
|
response.JSON(w, r, streamIDResponse{itemRefs, continuation})
|
|
|
}
|
|
|
|
|
|
-func (h *handler) markAllAsReadHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
+func (h *greaderHandler) markAllAsReadHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
userID := request.UserID(r)
|
|
|
clientIP := request.ClientIP(r)
|
|
|
|
|
|
@@ -1289,3 +1231,69 @@ func (h *handler) markAllAsReadHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
response.Text(w, r, "OK")
|
|
|
}
|
|
|
+
|
|
|
+func checkAndSimplifyTags(addTags []Stream, removeTags []Stream) (map[StreamType]bool, error) {
|
|
|
+ tags := make(map[StreamType]bool)
|
|
|
+ for _, s := range addTags {
|
|
|
+ switch s.Type {
|
|
|
+ case ReadStream:
|
|
|
+ if _, ok := tags[KeptUnreadStream]; ok {
|
|
|
+ return nil, errSimultaneously
|
|
|
+ }
|
|
|
+ tags[ReadStream] = true
|
|
|
+ case KeptUnreadStream:
|
|
|
+ if _, ok := tags[ReadStream]; ok {
|
|
|
+ return nil, errSimultaneously
|
|
|
+ }
|
|
|
+ tags[ReadStream] = false
|
|
|
+ case StarredStream:
|
|
|
+ tags[StarredStream] = true
|
|
|
+ case BroadcastStream, LikeStream:
|
|
|
+ slog.Debug("Broadcast & Like tags are not implemented!")
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("googlereader: unsupported tag type: %s", s.Type)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, s := range removeTags {
|
|
|
+ switch s.Type {
|
|
|
+ case ReadStream:
|
|
|
+ if _, ok := tags[ReadStream]; ok {
|
|
|
+ return nil, errSimultaneously
|
|
|
+ }
|
|
|
+ tags[ReadStream] = false
|
|
|
+ case KeptUnreadStream:
|
|
|
+ if _, ok := tags[ReadStream]; ok {
|
|
|
+ return nil, errSimultaneously
|
|
|
+ }
|
|
|
+ tags[ReadStream] = true
|
|
|
+ case StarredStream:
|
|
|
+ if _, ok := tags[StarredStream]; ok {
|
|
|
+ return nil, fmt.Errorf("googlereader: %s should not be supplied for add and remove simultaneously", starredStreamSuffix)
|
|
|
+ }
|
|
|
+ tags[StarredStream] = false
|
|
|
+ case BroadcastStream, LikeStream:
|
|
|
+ slog.Debug("Broadcast & Like tags are not implemented!")
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("googlereader: unsupported tag type: %s", s.Type)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return tags, nil
|
|
|
+}
|
|
|
+
|
|
|
+func checkOutputFormat(r *http.Request) error {
|
|
|
+ var output string
|
|
|
+ if r.Method == http.MethodPost {
|
|
|
+ err := r.ParseForm()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ output = r.Form.Get("output")
|
|
|
+ } else {
|
|
|
+ output = request.QueryStringParam(r, "output", "")
|
|
|
+ }
|
|
|
+ if output != "json" {
|
|
|
+ return errors.New("googlereader: only json output is supported")
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|