diff options
author | 2023-10-21 19:50:29 -0700 | |
---|---|---|
committer | 2023-10-22 13:09:30 -0700 | |
commit | 14e25ab9fe09b9951b38e56af2bdff7a0737b280 (patch) | |
tree | 1e466305ccf868d0253b09895af29f811a3e3393 /internal/api | |
parent | 120aabfbcef4ef453d70861aece3b107b603a911 (diff) | |
download | v2-14e25ab9fe09b9951b38e56af2bdff7a0737b280.tar.gz v2-14e25ab9fe09b9951b38e56af2bdff7a0737b280.tar.zst v2-14e25ab9fe09b9951b38e56af2bdff7a0737b280.zip |
Refactor HTTP Client and LocalizedError packages
Diffstat (limited to 'internal/api')
-rw-r--r-- | internal/api/feed.go | 12 | ||||
-rw-r--r-- | internal/api/subscription.go | 9 |
2 files changed, 11 insertions, 10 deletions
diff --git a/internal/api/feed.go b/internal/api/feed.go index 27f93ab7..33973402 100644 --- a/internal/api/feed.go +++ b/internal/api/feed.go @@ -41,9 +41,9 @@ func (h *handler) createFeed(w http.ResponseWriter, r *http.Request) { return } - feed, err := feedHandler.CreateFeed(h.store, userID, &feedCreationRequest) - if err != nil { - json.ServerError(w, r, err) + feed, localizedError := feedHandler.CreateFeed(h.store, userID, &feedCreationRequest) + if localizedError != nil { + json.ServerError(w, r, localizedError.Error()) return } @@ -59,9 +59,9 @@ func (h *handler) refreshFeed(w http.ResponseWriter, r *http.Request) { return } - err := feedHandler.RefreshFeed(h.store, userID, feedID, false) - if err != nil { - json.ServerError(w, r, err) + localizedError := feedHandler.RefreshFeed(h.store, userID, feedID, false) + if localizedError != nil { + json.ServerError(w, r, localizedError.Error()) return } diff --git a/internal/api/subscription.go b/internal/api/subscription.go index eb744419..499d99a0 100644 --- a/internal/api/subscription.go +++ b/internal/api/subscription.go @@ -32,7 +32,7 @@ func (h *handler) discoverSubscriptions(w http.ResponseWriter, r *http.Request) rssbridgeURL = intg.RSSBridgeURL } - subscriptions, finderErr := subscription.FindSubscriptions( + subscriptions, localizedError := subscription.FindSubscriptions( subscriptionDiscoveryRequest.URL, subscriptionDiscoveryRequest.UserAgent, subscriptionDiscoveryRequest.Cookie, @@ -42,12 +42,13 @@ func (h *handler) discoverSubscriptions(w http.ResponseWriter, r *http.Request) subscriptionDiscoveryRequest.AllowSelfSignedCertificates, rssbridgeURL, ) - if finderErr != nil { - json.ServerError(w, r, finderErr) + + if localizedError != nil { + json.ServerError(w, r, localizedError.Error()) return } - if subscriptions == nil { + if len(subscriptions) == 0 { json.NotFound(w, r) return } |