~ttt/minifluxlite

minifluxlite/api/subscription.go -rw-r--r-- 846 bytes
a04fe1aa — Frédéric Guillot Update Docker image to Alpine Linux 3.10.0 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2017 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.

package api // import "miniflux.app/api"

import (
	"net/http"

	"miniflux.app/http/response/json"
	"miniflux.app/reader/subscription"
)

func (h *handler) getSubscriptions(w http.ResponseWriter, r *http.Request) {
	subscriptionInfo, bodyErr := decodeURLPayload(r.Body)
	if bodyErr != nil {
		json.BadRequest(w, r, bodyErr)
		return
	}

	subscriptions, finderErr := subscription.FindSubscriptions(
		subscriptionInfo.URL,
		subscriptionInfo.UserAgent,
		subscriptionInfo.Username,
		subscriptionInfo.Password,
	)
	if finderErr != nil {
		json.ServerError(w, r, finderErr)
		return
	}

	if subscriptions == nil {
		json.NotFound(w, r)
		return
	}

	json.OK(w, r, subscriptions)
}