From 83f730dbf267b63e7bb92f6341ae64ecc9ef398b Mon Sep 17 00:00:00 2001 From: akuma06 Date: Thu, 20 Jul 2017 23:06:20 +0200 Subject: [PATCH] Fix #1251 by implementing the page parameter in the url. Now /p/xx works but also ?page=xx in api search/index --- apidoc/api_data.js | 14 +++++++------- apidoc/api_data.json | 14 +++++++------- apidoc/api_project.js | 2 +- apidoc/api_project.json | 2 +- controllers/api/api.go | 3 ++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/apidoc/api_data.js b/apidoc/api_data.js index 662ae457..29fd1192 100644 --- a/apidoc/api_data.js +++ b/apidoc/api_data.js @@ -23,6 +23,13 @@ define({ "api": [ "field": "q", "description": "

Query to search (torrent name).

" }, + { + "group": "Parameter", + "type": "Number", + "optional": false, + "field": "page", + "description": "

Page of the search results.

" + }, { "group": "Parameter", "type": "String", @@ -120,13 +127,6 @@ define({ "api": [ "optional": false, "field": "lang", "description": "

Filter the languages.

" - }, - { - "group": "Parameter", - "type": "Number", - "optional": false, - "field": "page", - "description": "

Search page.

" } ] } diff --git a/apidoc/api_data.json b/apidoc/api_data.json index 465873c6..57f88d46 100644 --- a/apidoc/api_data.json +++ b/apidoc/api_data.json @@ -23,6 +23,13 @@ "field": "q", "description": "

Query to search (torrent name).

" }, + { + "group": "Parameter", + "type": "Number", + "optional": false, + "field": "page", + "description": "

Page of the search results.

" + }, { "group": "Parameter", "type": "String", @@ -120,13 +127,6 @@ "optional": false, "field": "lang", "description": "

Filter the languages.

" - }, - { - "group": "Parameter", - "type": "Number", - "optional": false, - "field": "page", - "description": "

Search page.

" } ] } diff --git a/apidoc/api_project.js b/apidoc/api_project.js index 1183570c..cad61d5a 100644 --- a/apidoc/api_project.js +++ b/apidoc/api_project.js @@ -26,7 +26,7 @@ define({ "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2017-07-20T18:53:30.209Z", + "time": "2017-07-20T21:04:54.468Z", "url": "http://apidocjs.com", "version": "0.17.6" } diff --git a/apidoc/api_project.json b/apidoc/api_project.json index 821c113e..6cc79c91 100644 --- a/apidoc/api_project.json +++ b/apidoc/api_project.json @@ -26,7 +26,7 @@ "apidoc": "0.3.0", "generator": { "name": "apidoc", - "time": "2017-07-20T18:53:30.209Z", + "time": "2017-07-20T21:04:54.468Z", "url": "http://apidocjs.com", "version": "0.17.6" } diff --git a/controllers/api/api.go b/controllers/api/api.go index 84dcef31..0e171a93 100644 --- a/controllers/api/api.go +++ b/controllers/api/api.go @@ -374,6 +374,7 @@ func APIUpdateHandler(c *gin.Context) { * * @apiParam {String[]} c In which categories to search. * @apiParam {String} q Query to search (torrent name). + * @apiParam {Number} page Page of the search results. * @apiParam {String} limit Number of results per page. * @apiParam {String} userID Uploader ID owning the torrents. * @apiParam {String} fromID Show results with torrents ID superior to this. @@ -405,7 +406,7 @@ func APIUpdateHandler(c *gin.Context) { // APISearchHandler : Controller for searching with api func APISearchHandler(c *gin.Context) { c.Header("Content-Type", "application/json") - page := c.Param("page") + page := c.DefaultQuery("page", c.Param("page")) currentUser := router.GetUser(c) // db params url