subscription.go 846 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2017 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package api // import "miniflux.app/api"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/response/json"
  8. "miniflux.app/reader/subscription"
  9. )
  10. func (h *handler) getSubscriptions(w http.ResponseWriter, r *http.Request) {
  11. subscriptionInfo, bodyErr := decodeURLPayload(r.Body)
  12. if bodyErr != nil {
  13. json.BadRequest(w, r, bodyErr)
  14. return
  15. }
  16. subscriptions, finderErr := subscription.FindSubscriptions(
  17. subscriptionInfo.URL,
  18. subscriptionInfo.UserAgent,
  19. subscriptionInfo.Username,
  20. subscriptionInfo.Password,
  21. )
  22. if finderErr != nil {
  23. json.ServerError(w, r, finderErr)
  24. return
  25. }
  26. if subscriptions == nil {
  27. json.NotFound(w, r)
  28. return
  29. }
  30. json.OK(w, r, subscriptions)
  31. }