Просмотр исходного кода

refactor(api): move entryIDsResponse struct to messages.go

Keep all API message types together in messages.go.
Frédéric Guillot 1 день назад
Родитель
Сommit
15505142fd
2 измененных файлов с 14 добавлено и 14 удалено
  1. 9 14
      internal/api/entry_handlers.go
  2. 5 0
      internal/api/messages.go

+ 9 - 14
internal/api/entry_handlers.go

@@ -507,20 +507,6 @@ func (h *handler) fetchContentHandler(w http.ResponseWriter, r *http.Request) {
 	response.JSON(w, r, entryContentResponse{Content: mediaproxy.RewriteDocumentWithAbsoluteProxyURL(entry.Content), ReadingTime: entry.ReadingTime})
 }
 
-type entryIDsResponse struct {
-	Total    int     `json:"total"`
-	EntryIDs []int64 `json:"entry_ids"`
-}
-
-func parseEntryIDsParams(r *http.Request) (limit, offset int) {
-	limit = request.QueryIntParam(r, "limit", model.MaxEntryIDsLimit)
-	if limit <= 0 || limit > model.MaxEntryIDsLimit {
-		limit = model.MaxEntryIDsLimit
-	}
-	offset = request.QueryIntParam(r, "offset", 0)
-	return limit, offset
-}
-
 func (h *handler) getEntryIDsHandler(w http.ResponseWriter, r *http.Request) {
 	if request.HasQueryParam(r, "starred") {
 		starredValue := request.QueryStringParam(r, "starred", "")
@@ -617,3 +603,12 @@ func configureFilters(builder *storage.EntryQueryBuilder, r *http.Request) *stor
 
 	return builder
 }
+
+func parseEntryIDsParams(r *http.Request) (limit, offset int) {
+	limit = request.QueryIntParam(r, "limit", model.MaxEntryIDsLimit)
+	if limit <= 0 || limit > model.MaxEntryIDsLimit {
+		limit = model.MaxEntryIDsLimit
+	}
+	offset = request.QueryIntParam(r, "offset", 0)
+	return limit, offset
+}

+ 5 - 0
internal/api/messages.go

@@ -26,6 +26,11 @@ type entryIDResponse struct {
 	ID int64 `json:"id"`
 }
 
+type entryIDsResponse struct {
+	Total    int     `json:"total"`
+	EntryIDs []int64 `json:"entry_ids"`
+}
+
 type entryContentResponse struct {
 	Content     string `json:"content"`
 	ReadingTime int    `json:"reading_time"`